Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4185199

native2ascii -reverse results with sun.io.UnknownCharacterException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • None

      native2ascii -reverse results with sun.io.UnknownCharacterException for the following encoding_names: 8859_6, Cp420, MacSymbol.
      The input file is:
      \u3092\u8aad\u307f\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002

      Also:
      native2ascii -reverse -encoding JIS0208 input.txt native.txt
        where input file is as above, converts the file to following native-encoded characters:
      $rFI$_9~$`$3$H$,$G$-$^$;$s!#

      Then, trying to go back from native.txt, which is the output from above, to unicode characters, you get an output file that is identical to native.txt:
      native2ascii -encoding JIS0208 native.txt output.txt
      --------------------------------
      Here's the script that exhibits the problem:
      #!/bin/ksh

      # Check if JAVA_HOME is defined in the environment, if not
      # exit.

      if [ -z $JAVA_HOME ]
      then
        echo "JAVA_HOME should be defined and exported in TongaSetup.ini"
        exit 1
      fi

      if [ $# -eq 0 ]; then
        testWorkDir=./
        export CLASSPATH=.
      else
        testWorkDir=${1}
        export CLASSPATH=${testWorkDir}
      fi

      if [ -f ${testWorkDir}native.* ]; then
        rm -f ${testWorkDir}native.*
      fi

      if [ -f ${testWorkDir}output.* ]; then
        rm -f ${testWorkDir}output.*
      fi

      if [ -f ${testWorkDir}unicode.* ]; then
        rm -f ${testWorkDir}unicode.*
      fi

      NATIVE2ASCII=${JAVA_HOME}/bin/native2ascii
      ENCODING_LIST="8859_6 Cp420 JIS0208 MacSymbol";
      KSHSTAT=0

      for i in ${ENCODING_LIST}
      do

        # convert a unicode encoded text (input.txt) to a native encoded text (native.txt)
        # according to the encoding_name supplied from the ENCODING_LIST.
        ${NATIVE2ASCII} -reverse -encoding ${i} ${testWorkDir}input.txt > ${testWorkDir}native.${i}.txt 2>&1

        # convert the native encoded text you just got back to a unicode encoded text (output.txt).
        ${NATIVE2ASCII} -encoding ${i} ${testWorkDir}native.${i}.txt > ${testWorkDir}output.${i}.txt 2>&1
        
        # find any discrepancies between the original unicode encoded text and the output unicode
        # encoded text. The two files should be identical.
        diff ${testWorkDir}input.txt ${testWorkDir}output.${i}.txt > ${testWorkDir}unicode.${i}.diff
        STATUS=$?
        echo ${i}':'${STATUS}' expecting '${i}':0'
        if [ ${STATUS} != "0" ]; then
          echo ' >>bad result-check revrese encoding on '${i}'.'
          KSHSTAT=1
        fi
       
      done
       
      exit ${KSHSTAT}

      anat.kremer@Eng 1998-10-28

            sherman Xueming Shen
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: