Re: Writing Unicode-16 to a text file

From: Konrad Den Ende (chamsterkonrad_at_bigfoot.com)
Date: 01/24/04


Date: Sat, 24 Jan 2004 01:04:06 +0100


> When you wrote the characters to a file (what method did you use?) they
> probably underwent a 16-bit to 8-bit conversion

try {
   BufferedWriter writer = new BufferedWriter (new FileWriter
("nihongo.txt"));
   writer.write (cc); // cc is a char[] that stores the characters
   writer.close ();
}
catch (Exception e) {System.out.println (e.getMessage ());}

> using some encoding (what encoding did you specify? or what is your Java
> installation using as its default encoding?).

I didn't specify any encoding so i guess it's english. BUT i figured that
since
char is not more than a number then my char[] variable is just an array of
some
kind of integers (2-byte, i guess, so it will contain all the 65k
characters).

> When you looked at the file afterwards, the software you used to do that
> (what did you use?) probably wasn't set up to grok that encoding.

I used MS Word and a text reader with enabled japanese. Just to be sure i
checked a file that i can read japanese text from using my usual software,
and read from it using notepad. I didn's see japanese (oh, what a surprise)
but i could see a number of strange characters.
Yet, the file that my application creates, contains only "?"'s.

> What happens when you read the file back into Java?

"?"'s only.

Any hint?

-- 
Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.
Sleep - thing used by ineffective people
            as a substitute for coffee
Ambition - a poor excuse for not having
                 enough sense to be lazy
---------------------------------------------------


Relevant Pages

  • Re: [OT] A question for people with English OS
    ... without special settings or is it garbled text? ... This may seem like a silly question but I have always used a Japanese ... many web page authors fail to specify the encoding ... and only one of them shows some readable characters. ...
    (comp.lang.ruby)
  • Re: How to read unicode
    ... Japanese Unicode characters but not sure where to begin if I need ot ... Japanese version of Windows XP? ... The other is to specify a character encoding. ...
    (comp.lang.java.programmer)
  • Re: Writing Unicode-16 to a text file
    ... You have been writing Japanese with an encoding that doensn't support ... It does not support Japanese. ... level of abstraction, namely characters. ...
    (comp.lang.java)
  • Re: How to change OE so the coding is right automatically
    ... Incidentally they also cause trouble with OE ... - it will not post them in any "Japanese" encoding only so you need to ... characters without testing them first. ...
    (sci.lang.japan)
  • Re: Strange Characters When Viewing Outlook Express messages
    ... Messages Received in Outlook Express Have Different Characters in the ... messages in the default encoding format regardless of the actual encoding ... changed something with whatever they use to produce the emails. ...
    (microsoft.public.windowsxp.general)