Results 1 to 11 of 11

Thread: Working With Unicode Data [Displaying] etc ... I'm stumped!

  1. #1

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Working With Unicode Data [Displaying] etc ... I'm stumped!

    Hello everyone, I tried working with unicode data yesterday.

    Basically Japanese Characters. Pure not in the notation of \0xxxx something or other.

    I cannot seem to work it out property.. anyone has any ideas on how to solve this? thanks.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    The InputStreamReader class can be used to convert a byte stream to a character stream and it's analogue. OutputStreamWriter can be used to convert a character stream to a byte stream. Both of which enable you to set the encoding when they are created.
    Code:
    FileInputStream fis = new FileInputStream("test.txt");
    InputStreamReader isr = new InputStreamReader(fis, "sjis");

  3. #3

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    I tried that then data comes from the standard console... even tried a literal string... still it comes out garbage. :s

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    Just for clarification. The input to be transformed is comming from the standard console?

  5. #5

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    Quote Originally Posted by Dillinger4
    Just for clarification. The input to be transformed is comming from the standard console?

    yeah... using buffered stream readers. etc etc. even files :s

    sorry i fogot the bring my code for it. :s

    but i tried it on a literal string also. to no avail.

    Code:
    byte [] sjisbytes = "マリベル".getBytes("SJIS");


    and a couple of more variations


    did i use that correctly. :s

  6. #6
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    I found the following response to a question posed in the Java forums.
    http://forum.java.sun.com/thread.jsp...sageID=2758382
    ii) You mention a JVM default encoding alot. I presume
    > this is a system.property. which one ?

    No idea. You would have to dig into the VM source to figure it out. You can change it on the command line though. Presumably on windows it is tied to the language that you set when you initially install windows.

  7. #7
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    Maybe changing the Local might work.
    Code:
    import java.util.Locale; 
    
    Locale(String language)
    Locale(String language, String country)
    Locale(String language, String country, String variant)

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    Is your standard console even capable of displaying Japanese?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    yes it is. it displays error messages in japanese. :s

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    What happens when you directly write some Japanese characters to the console using System.out.println() ?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Working With Unicode Data [Displaying] etc ... I'm stumped!

    it displays square characters.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width