]> nuage.metani.fr Git - 3GPP.git/blobdiff - bin/docx2asn.sh
Remove CR and EN-Dash
[3GPP.git] / bin / docx2asn.sh
index f29e8c98ab3e2677e34e38bc3bf4ba1a48bfe9ef..373abb9c73ef72e8eba644c53348da7cb4a2f88c 100755 (executable)
@@ -11,7 +11,7 @@ if [[ ! -w . ]] ; then
     exit 1
 fi
 
-platform=$(uname -a)
+platform=$(uname)
 
 case $platform in
     Linux) libreoffice="libreoffice" ;;
@@ -47,6 +47,13 @@ while [ "$#" -gt 0 ]; do
            shift
            continue
        fi
+
+       # On windows, soffice adds CR characters at line ends and produces EN-DASH in Windows-1252 enconding, i.e. 0x96
+       # Remove the CR at each line end and convert EN-DASH to normal minus
+       echo "${1%.docx}.txt"
+       LC_ALL=C sed -i $'s/\x96/-/g' "${1%.docx}.txt"
+       LC_ALL=C sed -i $'s/\r$//' "${1%.docx}.txt"
+
     fi
 
     if [[ -e "${1%.docx}.asn" ]] ; then
@@ -54,7 +61,8 @@ while [ "$#" -gt 0 ]; do
        shift
        continue
     fi
-    
+
+       
     cat "${1%.docx}.txt" | awk '/^-- ASN1START$/,/^-- ASN1STOP$/' | grep -Evxe '-- ASN1ST(ART|OP)' | grep -v '^--' | awk 'NF || p; { p = NF }' p=0 > "${1%.docx}.asn"
 
     if [[ -e "${1%.docx}.asn" ]] ; then