Chinese texts in Java

Hi.
I'm using JBuilder to develop a gui in java.
All is in English and now I wan't to be able to do it in Chinese as well.
I have created resource files for the chinese text in a dialogue box, but all I get is awkward characters.
I have also tried this:
Locale chLocale = new Locale("zh", "CN");
this.setLocale(chLocale);
in the class implementing the dialogue - result: no change.
Obiously I haven't got it, when reading manuals, specs and howtos it seems very easy!
Please help me.
BR
Thomas

You shouldn't need it if you have the font.properties.zh. If font.properties.zh_CN does not exist, it then looks for font.properties.zh. If that doesn't exist it uses font.properties.
font.properties.zh is Simplified Chinese. (GB2312)
font.properties.zh_TW is Traditional Chinese. (BIG5)
As long as you have font.properties.zh, Simplified should work.
Assuming that this is correct, make sure that you have Simplified Chinese fonts installed on your system and that they are the GB2312 charset.
The local of the OS must be zh_CN, or you have to set that property as a java parameter when u start java.
I have done this in Linux, we changed the Locale of the OS and rebooted whenever we did a language change. I am not sure how you do it in windows, we ended up writing scripts to replace font.properties with font.properties.zh.
The easy thing is to just copy font.properties.zh to font.properties (backup the one you are replacing). This might be all you need for an overall solution. If you plan on switching between Japanese, and Chinese, it will require more work. You could merge those 3 font.properties, but the issue then becomes that some of the languages have the same unicode character but are drawn slightly different in Japanese than in Chinese.

Similar Messages

  • How to display/input/write Chinese Text in java

    Dear All,
    I am trying to make a very simple java program, where I am trying to display Chinese characters. I am trying to save them into a file (for now, later into db2). However, I seem to make no progress at all.
    I am completely lost with this one. I have googled and gone through a lot of sites like :
    http://www.mandarintools.com/javaconverter.html
    http://www.chinesecomputing.com/programming/java.html
    http://forum.java.sun.com/thread.jspa?threadID=442220&messageID=1995079
    http://www.linuxforum.net/chinese/develop/java.html
    I have downloaded the cyberbit.ttf into /jre/lib/fonts and updated the fonts.properties also.
    I have tried to compile with two different encoding options big5 and gb2132 as well.
    I have also tried to pick up a few unicodes from a site and tried .. for ex.
    String s = "\U+0061";but this results in Illegale Escape Char. exception.
    All I am trying to do is use a String reference, feed it with Chinese text, which again I copied from a site, and then display it on the console. Or even write it to a file.
    I am lost in the maze of Unicode, UTF -8 etc.
    I would be really glad if someone could lead me out of this.
    Thanks in advance.
    Rgds,

    Hi,
    So I tried to actually start working on the web app where this change is intended.
    I copied a chinese String from a website (pasted it in Word, and it pasted fine).
    Pasted it in the text box and saved this field. The value appears gibberish in db2 ( I am sure the tables arent specified for UTF-8).
    My app doesnt use any contentType or characterEncoding either.
    Then when I retrieve this value, it comes as exact same gibberish as in DB.
    But, behold, when I change the encoding (view -> encoding -> chinese (GB2312)) It displays the exact String that was inserted :-)
    Then I add these lines in my Jsp.
    <%@ page contentType="text/html; charset=GB2312" %>
    request.setCharacterEncoding("GB2312"); .
    so that I can make that chinese GB2312 as the default option. It does that. (The default was Western European (ISO).
    However now, it displays question marks (????) in that field.
    What options can I have ?
    TIA

  • Problem with retrieve the chinese text from oracle DB

    my running enviroment is
    Linux 6.0+ apache Jserv+java 1.1+oracle 8.05
    my db character set is zhs16cgb231280.
    when i retrieve the chinese text using servlet and forward to client browser. it doesnt display the text property.but if i transfer the data to an Applet. it will be ok.
    my knowledge is oracle using unicode to communicate between db and JDBC.
    So i dont know how to solve my problme.
    Who can help me?
    Thanks Advanced

    Hello,
    What's the charset of your database? Mine is AMERICAN_AMERICA.UTF8
    In this case, I could successfully insert and retrieve the Chinese characters without any encoding parameter in the getString() method. Perhaps you could try it.

  • Reading chinese text file

    How can a MIDlet read and display the content of the Chinese Text file on Canvas?
    ISO8859_1 / UTF8 / UTF16 used? Thanks!

    UTF-8 works for all java phone devices showing chinese? Thanks!

  • How to print a text in java?

    How to print a text in java?

    of corse, i have JTextField in my frame that i want to extract the text and print it on a paper with a printer.

  • Chinese text in Indesign CS3

    Hi,
    I have a computer (WXPSP3 EN) with Adobe Creative Suite CS3 (incl. InDesign) installed. Now the user has a problem with Chinese text, he never used before. He got a Word file with the translation English => Chinese and copied the text from Word to InDesing :-)
    The text is not displayed. It seems that there is a font missing, is this possible? Do I need a special InDesign font for Chinese text? If yes, which one? A link would be helpful. Thanks in advance for your help.

    I'm using chinese text, too, for the chinese version of the german/english user guides I'm creating.
    For me it never was a problem. You probably need to know this:
    1. In general, you need to install support for CJK (chinese, japanese, korean) language on Windows
        (Word may display the text without the support installed because it can embed fonts into .doc files)
    2. If you then copy text from Word to Indesign, it should be displayed correctly, whereas Indesign manages a list of substitution fonts for this situation
    If 2. does not work, you could try to replace the font in Word first by, for example, SimSun (of the chinese Windows fonts). Of course only if simplified chinese is used.
    Then copy and paste should. At least it does for me in CS2 and CS4.

  • How to print "Text" in JAVA(TM)....

    Does anyone know how to print "text" using Java?
    - Here's an example output...
    NOTE: # == 'empty spaces'
    --------------------------- <- Paper
    |###################|
    |####Welcome#########|
    |###################|
    |########to##########|
    |###########JAVA(TM)##|
    |###################|
    |#######Programming####|
    |###################|
    Please post a complete << SAMPLE CODE >> for printing the "text" (Welcome to JAVA(TM) Programming. Including the indentions. So it will not be like this...
    -------------------- <- Paper
    |Welcome |
    |to |
    |JAVA(TM) |
    |Programming |
    | |
    | |
    | |
    | |
    Thanks.

    Please read How To Ask Questions The Smart Way

  • How to output money number by text in java?

    How to output money number by text in java?
    Example: input: 1234 $
    output: one thousand two hundred thirty four dollar.

    try this...
    import java.text.DecimalFormat;
    public class EnglishNumberToWords {
      private static final String[] tensNames = {
        " ten",
        " twenty",
        " thirty",
        " forty",
        " fifty",
        " sixty",
        " seventy",
        " eighty",
        " ninety"
      private static final String[] numNames = {
        " one",
        " two",
        " three",
        " four",
        " five",
        " six",
        " seven",
        " eight",
        " nine",
        " ten",
        " eleven",
        " twelve",
        " thirteen",
        " fourteen",
        " fifteen",
        " sixteen",
        " seventeen",
        " eighteen",
        " nineteen"
      private static String convertLessThanOneThousand(int number) {
        String soFar;
        if (number % 100 < 20){
          soFar = numNames[number % 100];
          number /= 100;
        else {
          soFar = numNames[number % 10];
          number /= 10;
          soFar = tensNames[number % 10] + soFar;
          number /= 10;
        if (number == 0) return soFar;
        return numNames[number] + " hundred" + soFar;
      public static String convert(long number) {
        // 0 to 999 999 999 999
        if (number == 0) { return "zero"; }
        String snumber = Long.toString(number);
        // pad with "0"
        String mask = "000000000000";
        DecimalFormat df = new DecimalFormat(mask);
        snumber = df.format(number);
        // XXXnnnnnnnnn
        int billions = Integer.parseInt(snumber.substring(0,3));
        // nnnXXXnnnnnn
        int millions  = Integer.parseInt(snumber.substring(3,6));
        // nnnnnnXXXnnn
        int hundredThousands = Integer.parseInt(snumber.substring(6,9));
        // nnnnnnnnnXXX
        int thousands = Integer.parseInt(snumber.substring(9,12));   
        String tradBillions;
        switch (billions) {
        case 0:
          tradBillions = "";
          break;
        case 1 :
          tradBillions = convertLessThanOneThousand(billions)
          + " billion ";
          break;
        default :
          tradBillions = convertLessThanOneThousand(billions)
          + " billion ";
        String result =  tradBillions;
        String tradMillions;
        switch (millions) {
        case 0:
          tradMillions = "";
          break;
        case 1 :
          tradMillions = convertLessThanOneThousand(millions)
          + " million ";
          break;
        default :
          tradMillions = convertLessThanOneThousand(millions)
          + " million ";
        result =  result + tradMillions;
        String tradHundredThousands;
        switch (hundredThousands) {
        case 0:
          tradHundredThousands = "";
          break;
        case 1 :
          tradHundredThousands = "one thousand ";
          break;
        default :
          tradHundredThousands = convertLessThanOneThousand(hundredThousands)
          + " thousand ";
        result =  result + tradHundredThousands;
        String tradThousand;
        tradThousand = convertLessThanOneThousand(thousands);
        result =  result + tradThousand;
        // remove extra spaces!
        return result.replaceAll("^\\s+", "").replaceAll("\\b\\s{2,}\\b", " ");
       * testing
       * @param args
      public static void main(String[] args) {
        System.out.println("*** " + EnglishNumberToWords.convert(0));
        System.out.println("*** " + EnglishNumberToWords.convert(1));
        System.out.println("*** " + EnglishNumberToWords.convert(16));
        System.out.println("*** " + EnglishNumberToWords.convert(100));
        System.out.println("*** " + EnglishNumberToWords.convert(118));
        System.out.println("*** " + EnglishNumberToWords.convert(200));
        System.out.println("*** " + EnglishNumberToWords.convert(219));
        System.out.println("*** " + EnglishNumberToWords.convert(800));
        System.out.println("*** " + EnglishNumberToWords.convert(801));
        System.out.println("*** " + EnglishNumberToWords.convert(1316));
        System.out.println("*** " + EnglishNumberToWords.convert(1000000));
        System.out.println("*** " + EnglishNumberToWords.convert(2000000));
        System.out.println("*** " + EnglishNumberToWords.convert(3000200));
        System.out.println("*** " + EnglishNumberToWords.convert(700000));
        System.out.println("*** " + EnglishNumberToWords.convert(9000000));
        System.out.println("*** " + EnglishNumberToWords.convert(9001000));
        System.out.println("*** " + EnglishNumberToWords.convert(123456789));
        System.out.println("*** " + EnglishNumberToWords.convert(2147483647));
        System.out.println("*** " + EnglishNumberToWords.convert(3000000010L));
         *** zero
         *** one
         *** sixteen
         *** one hundred
         *** one hundred eighteen
         *** two hundred
         *** two hundred nineteen
         *** eight hundred
         *** eight hundred one
         *** one thousand three hundred sixteen
         *** one million
         *** two millions
         *** three millions two hundred
         *** seven hundred thousand
         *** nine millions
         *** nine millions one thousand
         *** one hundred twenty three millions four hundred
         **      fifty six thousand seven hundred eighty nine
         *** two billion one hundred forty seven millions
         **      four hundred eighty three thousand six hundred forty seven
         *** three billion ten
    }

  • Chinese text while downloading to excel

    Hello Everyone,
    I have one alv report in which text is coming into Chinese language.
    When i download my alv data to excel, chinese text is getting converted into #### characters.
    Anyone having idea how to download the chinese text from alv into excel.
    Thanks in advance.
    Regards,
    Tarun

    Hi,
    When you download in Excel, the character formats are taken from the Front end, besure that the chinese font is installed in your system, i.e. you OS should support the lanagugae format you are downloading to.
    Hope It Helps
    Anirban

  • Printing chinese text in a smartform.

    Whenever, I try to write chinese text in the smrtform, some weird characters appear. How can I paste chinese text in the smartform. Please provide me a solution.
    Moderator message: please do some research before asking.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    Edited by: Thomas Zloch on Feb 28, 2011 9:21 AM

    Please check with your basis that your output device support print Chinese character. Or, you can search more in forum, there are a lot of threads about print Chinese and other Unicode characters in form.
    Thanks,

  • How to create a xml element for Text with Java?

    Hi @ all,
    I want to tag a part of a text with Java.
    Like the InDesign function "Tag für Text" (maybe "tag for text" in english)
    Is there a way to tag text with Java?
    I tried to autoTag and to markup the text with an existing xml, but only got IdsExceptions.
    here the code where to tag the text:
    XMLElement newXML = parentXML.addXMLElement(VariableTypeUtils.createString("newXML"),OptArg.noVariableType());
    Text[] texts = para.findText(OptArg.noBoolean());
    for (Text text : texts)
       //TODO tag text
    Exception throwing code:
    text.autoTag();
    text.markup(newXML);
    newXML.markup(VariableTypeUtils.createObject(text));

    This is not a Web Dynpro specific question. This forum is for Web Dynpro specifc development aspects. There are other forums for general ABAP development as well as other specific aspects of ABAP development.
    I strong suggest that you review the rules of engagement for forum involvement, Derek.  You have had multiple violations of the rules in the last week.

  • How to read chinese text in Quickoffice

    I wish to know if there is any plugin that allows me to read chinese text (preferably in UTF-8 or UTF-16 encoding) in Quickoffice.
    There also don't seemed to be a free ebook reader that supports both english and chinese encoding.
    Anyway knows anything at all, please help. Thanks

    Use Read_text function module.
    you need to pass
    ID
    LANGUAGE
    NAME
    OBJECT   to the function moduel
    To find the Text id name language and object these are the following steps. Example: FB02
    1. goto FB02, Enter Document number
    2. from menuselect Goto>Header-->header Text..... New window will be displayed 
    3. select the Header Text. here you can see all the text. 
    4. click on the TEXT (which you want to know the Text id) , then press log ICON (you can find in bottom right of the text window) it looks like a rolled paper. 
    5. in the Next window you will find Text Name. Text ID, Language. etc...
    Regards,
    Lalit Mohan Gupta.

  • How to extract Chinese text from font embedded text PDF?

    This is actually font embedded text PDF (Used: type 1 fonts & custom encoding) and not scanned PDF, however I am unable to extract the "Chinese language" text properly and found only the garbled text when "Copy & Paste" (or save as RTF). Kindly refer the sample PDF attached for your reference.
    Kindly advise how could I solve this problem.
    Thanks in advance for your better solution.

    As I was unable to upload the sample page PDF in my original thread, I have shared now in the following path. Kindly look into this and guide me how to extract the chinese text as UNICODE text.
    Downloading: Chinese_Text_Extraction.pdf - Uploadingit

  • Display Chinese Text in Form 6i

    Hi,
    I am trying to put Chinese text on forms under Form 6i and allow users to enter double-byte Chinese characters.
    But Form 6i cannot display the Chinese text that I entered. A double-byte Chinese text is always displayed as '?' in the Form.
    I have changed all NLS_LANG registry entry to be AMERICAN_AMERICA.US7ASCII in all three my Windows 98/NT/2000 English PCs. The problem still can't be solved.... 8-(
    I uses Chinese Star to allow me to enter Chinese characters.
    Can someone enlight me on this issue?
    Thanks!

    Hi :
    1) change your NLS_LANG registry entry to be SIMPLIFIED CHINESE_CHINA.ZHS16GBK
    2) open the Chinese Star
    3) run your application
    I think this will solve this problem.

  • How do I copy and paste Chinese text into InDesign CC?

    I am having difficulty copying and pasting pre-translated Chinese text into InDesign.
    Many of the characters are coming up as boxes in the majority of Chinese fonts offered in CC.
    马修斯旅游大巴租赁公司
    爱尔兰和英国之旅
    translates as
    Font used above is Apple LiSung
    I have tried to import via Apple Text Edit and format stripped the text.

    That's happening because you have Simplified Chinese text, and are attempting to use a Traditional Chinese font.
    Ellis suggests a well-made Adobe font with Trad support. If you pull down your font dropdown and scroll towards the end, you'll find fonts split into categories according to language support. The one with Apple LiSung is the Simplified category, and the one with Adobe Fangsong is the Trad category. Pick any font from that category - but know that the style of font you pick in Chinese means as much as the style of font you pick in English, and if you don't know what the conventions are, you may well choose one not entirely suited to your audience. (One of my translators likened the Chinese font choices of monolingual Anglo designers to "seeing the body text of my How To Use Your Health Care Benefits brochure laid out in Rosewood.")

Maybe you are looking for