Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

Good day!

How can I internationalize a smartdevice application. I want to display all data to datagrid in asian languages(Chinese, Vietnamese, etc) I create a resource file for each languages. My problem is, it was not able to display the correct string(还是用中文吧) instead it will display a garbage string o boxes. No problem in english it will display properly.


code:
C#
private void Form1_Load(object sender, EventArgs e)
        {
            customersBindingSource = new BindingSource();
            List<customers> custList = new List<customers>();
            custList = Customers.GetAllCustomers();
            customersBindingSource.DataSource = custList;
            dataGrid1.DataSource = customersBindingSource;
            dataGrid1.TableStyles[0].GridColumnStyles[0].HeaderText = ResWMSPDA.Code_ZH;
            dataGrid1.TableStyles[0].GridColumnStyles[1].HeaderText =   ResWMSPDA.Name_ZH;
            dataGrid1.TableStyles[0].GridColumnStyles[2].HeaderText = ResWMSPDA.Address_ZH;
            dataGrid1.Dock = DockStyle.Fill;
        }
</customers></customers>

C#
public class Customers
    {
        public string code { get; set; }
        public string name { get; set; }
        public string address { get; set; }

        public Customers(string code, string name, string address)
        {
            this.code = code;
            this.name = name;
            this.address = address;
        }

        public static List<customers> GetAllCustomers()
        {
            List<customers> tempCustomers = new List<customers>();
            Customers customer1 = new Customers("1","Customer 1","Address 1" );
            Customers customer2 = new Customers("2", "Customer 2", "Address 2");
            Customers customer3 = new Customers("3", "客户 3", "地址 3");
            Customers customer4 = new Customers("4", "客户 4", "地址 4");

            tempCustomers.Add(customer1);
            tempCustomers.Add(customer2);
            tempCustomers.Add(customer3);
            tempCustomers.Add(customer4);

            return tempCustomers;
        }
    }
</customers></customers></customers>


output:
All chinese charaters display garbage string or boxes.





Any help is highly appreciated.


Thanks you very much.
Posted
Updated 18-Sep-11 16:25pm
v2

1 solution

Those boxes is a sign of using the font not supporting the characters you use. You need just to use the right font. Use "Character Map" (charmap.exe) application bundled with every version of Windows to see what font support which Unicode code point ranges. For example, the font "Arial Unicode MS" is the font deployed with Windows which support the most. In particular, support of Chinese, Vietnamese and most European and Indic scripts is not a problem. You can face some problems only with some exotic scripts and may need to find the fonts on the Web, which is getting more and more feasible.

—SA
 
Share this answer
 
Comments
Gerry Logrosa 18-Sep-11 22:42pm    
yes, the font I used is from charmap.exe but still display garbage. I have also installed "simsun & Nsimsun" font.
Gerry Logrosa 19-Sep-11 1:34am    
Is mobile-based application uses the same font with the windows-based? Because i'd tried in windows-based the chinese strings will display properly.
Sergey Alexandrovich Kryukov 22-Sep-11 10:45am    
It must be Windows mobile, right? Should be the same. Can you test your application of a part of it on regular Windows XP, Windows 7?
Some mess related to non-Unicode legacy encoding can be involved. How are you sure the text is presented in correct Unicode?

Also, you can write some text in some Unicode UTF but read assuming some different UTF, so the question is: where is the origin of your text?

Also, can you make a simple experiment: write some text as immediate constant hard-coded in your code, in the form of hexadecimal code points you know (from Charmap or http://www.Unicode.org) in the form U+...? This way, your code will be all in ASCII, but the text will represent correct Unicode in required range of code point. Check up is it is rendered correctly...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900