We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › How to view Chinese text
Page Index Toggle Pages: 1
How to view Chinese text? (Read 1646 times)
How to view Chinese text?
Feb 12th, 2008, 10:00am
 
I'm pulling Chinese content from MySQL.  I'm certain the data is properly stored in MySQL.  I'm unable to see the Chinese characters when I use text().  I see "??" in the console when I use println().  I'm running English Win XP.  

Do I need to use a unicode font?  Do I need to use some sort of String processing for UTF-8?

I've also tried to hardcode a String with Chinese text, but that results in the same "??" problem.  
String cn = "chinese text here";

I also noticed that unicode is not saved in a pde file.

What am I missing here?  I'm sure that this problem has been seen by many users.

thanks!
Re: How to view Chinese text?
Reply #1 - Feb 12th, 2008, 10:38am
 
- make sure you check "All Characters" when creating your vlw font in processing

- check that the console-font supports the chars you need (see preferences.txt -> "console.font=...")

- try loading utf-8 text from a file (since rev 134 processing reads files as utf-8) and println()

- check your java-log (does winxp have that?) to see what ends up in there when you println()

F
Re: How to view Chinese text?
Reply #2 - Feb 12th, 2008, 11:21am
 
Thanks for the info.  Here is what I've done so far without any success:

1.  "make sure you check "All Characters" when creating your vlw font in processing."

I created a vlw font from MS_Song-20, which is an installed Chinese font on Win XP.  The vlw file is 7.35 MB and results in a Out of Memory error when I run the applet.

2.  "check that the console-font supports the chars you need (see preferences.txt -> "console.font=...")"

Changed to MS_Song, but the console still prints "??".

3.  "try loading utf-8 text from a file (since rev 134 processing reads files as utf-8 and println() ".

I'm running rev 135 Beta.  I tried to read from a text file using code from this entry  http://processing.org/discourse/yabb_beta/YaBB.cgi?board=OpenGL;action=display;num=1176716495;start=0#0.  The console printed "??", the sketch rendered boxes...which is more than I saw before.

4.  "check your java-log (does winxp have that?) to see what ends up in there when you println()".

I don't know where to locate the java log file.  I'll look around...
Re: How to view Chinese text?
Reply #3 - Feb 13th, 2008, 8:14pm
 
1. that's because you'll have a ridiculous number of characters and it's trying to load them all as images. use createFont() in your code and specify a charset:
http://processing.org/reference/createFont_.html

1b. read the troubleshooting page on OutOfMemoryErrors.
http://processing.org/reference/troubleshooting/index.html

2. the java console isn't any good at handling encodings properly, so ?? in the console is not a good indicator of whether things are working. use the text() function and see what results you get.

3. see #2.

4. the location of the java log for windows is also described on the troubleshooting page.
Re: How to view Chinese text?
Reply #4 - Feb 16th, 2008, 4:23am
 
Ok, I figured it out.

1.  Install the East Asian Language files.  I downloaded them from BitTorrent.

2.  Use createFont(); and choose a font from the East Asian language pack.  Don't use the create font tool to create a .vlw because it eats up memory.

PFont sysFont= createFont("mingliu", 18);

3.  You can use String cn = "chinese text here";  No additional UTF-8 casting is necessary.  I'm pulling the Chinese text from MySQL.  Hardcoded Chinese text may be problematic.

4.  I can't get the console to prinln() Chinese text, but I can live without it.
Page Index Toggle Pages: 1