5 Replies Latest reply: Dec 7, 2007 12:34 PM by 807603 RSS

    How do i use an input file with Asian characters(Unicode)?

    807603
      /* Ardor
       * Illiteraminator.java 
       * Version beta 1.0
       * December 7, 2007
       * Main interfacing class
       */
      
      import java.io.*;
      import java.util.*;
      
      public class Illiteraminator{
        public static void main (String [] args){
        //  ArrayList<Word> dictionary = new ArrayList<Word>();
          String fileName = "Mandrin.txt";
          String character= "",definition = "",inputLine;
          
          try{
            Scanner fileScan = new Scanner (new File (fileName));
            while (fileScan.hasNext()){
              inputLine = fileScan.nextLine();
              Scanner sc = new Scanner(inputLine);
              character = sc.next();
              while (sc.hasNext()){
                definition = definition + " " + sc.next();
              }//end while sc
              
             // dictionary.add(new Word(character, definition));
              //definition = "";
              //character = "";
            }//end while fileScan
          } catch (FileNotFoundException e){
            System.out.println("File not found, dig around for Mandrin.txt");
            System.exit(1);
          }//end catch
          
          System.out.println(character);
          System.out.println(definition);
        }//end main
        
      }//end class Illiteraminator
      Hi, i'm a first time programmer. Never touched programming until i took a Java class in university last semester. I am currently attempting to write a program to help me move away from my illiteracy in Mandrin. So, that's my code, and i am using Dr.Java while writing it. When i tested it out the output looked something like this v
      A p p l e
      M o n k e y C a t D o n k e y

      My input file is saved in Unicode. It contains letters that cannot be saved in ANSI. I tried UTF-8, but the interactions section showed no output...

      Is this just a problem with Dr.Java? Will i encounter a similar problem when i turn this into a GUI?

      The following is a copy and pasted version of the txt file i used as input. It is saved in the Unicode format.

      &#30340;[de] <grammatical particle marking genitive as well as simple and composed adjectives>; &#25105;* w&#466;de my; &#39640;* g&#257;ode high, tall; &#26159;* sh�de that's it, that's right; &#26159;...* sh�...de one who...; &#20182;&#26159;&#35828;&#27721;&#35821;*. T&#257; sh� shu&#333; H�ny&#468;de. He is one who speaks Chinese. [d�] &#30446;* m�d� goal [d�] true, real; *&#30830; d�qu� certainly
      &#19968;(A&#22777;)     [y&#299;] one, a little; &#31532;* d�-y&#299; first, primary; &#30475;*&#30475; k�ny&#299;k�n have a (quick) look at [y�] (used before tone #4); *&#20010;&#20154; y� g� r�n one person; *&#23450; y�d�ng certain; *&#26679; y�y�ng same; *&#26376;y�yu� January [y�] (used before tones #2 and #3); *&#28857;&#20799; y�di&#462;nr a little; *&#20123; y�xi&#275; some {Compare with &#24186;(F&#20040;) y&#257;o, which also means "one"}
      &#26159;     [sh�] to be, *&#19981;*? sh�bush�? is (it) or is (it) not?; *&#21542; sh�f&#466;u whether or not, is (it) or is (it) not?