Groups | Blog | Home
all groups > c# > march 2004 >

c# : Multilingaul support


faktujaa
3/13/2004 10:31:05 PM
I want to make our application support multiple languages. I have gone through many articles which only describes about making ur application display user interface data in different languages using Globalization, and Rsources namespaces
But my main problem is how to handle the user input data. If i am not wrong, i have to store the user input data (in different languages English, Chinese, etc) in unicode format in database than how to achieve this in windows-based application using C#. Any examples????? Do i have to change the data type for each field in table from char/varchar to unicode????? Please help. Thanx in advance
faktujaa
3/14/2004 7:56:05 AM
Hi Sherif
Sherif ElMetainy
3/14/2004 9:25:11 AM
Hello

Strings in c# use unicode character set, so you don't have to worry about
that. But your database has to use unicode too. Change char/varchar/text
fields to nchar/nvarchar/ntext.

Best regards,
Sherif

[quoted text, click to view]
through many articles which only describes about making ur application
display user interface data in different languages using Globalization, and
Rsources namespaces.
[quoted text, click to view]
wrong, i have to store the user input data (in different languages English,
Chinese, etc) in unicode format in database than how to achieve this in
windows-based application using C#. Any examples????? Do i have to change
the data type for each field in table from char/varchar to unicode?????
Please help. Thanx in advance.
[quoted text, click to view]

Sherif ElMetainy
3/15/2004 1:04:03 AM
Hello

As long as you use unicode datatypes (nvarchar, nchar, ntext), and
paramterized queries, you don't have to worry about queries. Of course the
length of the data can be language dependent, so you have to make the fields
big enough to hold information in all suported languages.

As for numbers and dates, they should never be stored in the database as
strings. Instead use bigint/int/smallint/tinyint/decimal/real datatypes for
numbers (depending on the type of number) and use datetime / smalldatetime
for dates. Then let .NET handle parsing dates and numbers and formatting
them for display depending on the culture used.

Best regards
Sherif

[quoted text, click to view]
make make my application international. Say for example, I have a chinese
user, he enters all his data in chinese language. I have made UI to display
chinese using CultureInfo and resource files. Now the chinese data has to be
stored in database. One thing for sure that it will occupy more/less space
than the english characters(I am not sure). So it is better to change the
database types to nchar/nvarchar/ntext as u say. But don't we have to store
the data in bytes to display it properly later. For example: Hello World in
chinese will be stored in database field Name as it is but when we see the
data appears to be junk, so will it display properly on the front end
without no query change. Don't we have to say SELECT ASCII(Name) from TABLE.
Another thing for all the above data types, can we use string to access
data?????? bcoz in C++, COM, we use to specify corresponding datatype for
datatype in SQL. This is all about string but how do we take care of
numbers. For example, numbers in Asian language-Hindi is having a different
format. Also dates???? I am dead by now. Please help. Thanx in advance.

faktujaa
3/16/2004 7:46:09 PM
Hi Sherif
Just to make it clear, u mean to say that we have to do only one change in database for multilingual support i.e. Changing char/varchar/text fields to nchar/nvarchar/ntext. Rest all other data types we can use as it is ex: datetime, integers, floats, etc. The .NET runtime will take care of displaying them in appropriate format depending on the culture info. Secondly we don't have to code anything extra in C# to make this work expect for displaying label and form identifiers from resource files depending upon culture info. Now the big problem - You are saying as long as you use parameterized query. Actually i am selecting/ inserting/updating data from/to database by simply forming queries using stringbulider - like INSERT INTO XYZ VALUES('X', 'Y'). This whole statement is executed using command object. Same is the case with SELECT and UPDATE. So is this a problem?????? please help. Thanx in advance

Sherif ElMetainy
3/17/2004 6:47:24 PM
Hello

The concatenation of strings will not work unless you use N'X', i.e. you
must put an N before the single quote, so that SQL server knows this is
unicode. But this is not a recomended practise. A single quote in the string
will break your query and breaks security because it allows SQL injection,
unless you write code to escape the strings. Parameterized queries will
relieve you from escaping string and will improve the performance.
In case of displaying data, you may have to worry about left to right and
right to left if you support right to left languages like arabic and hebrew.

Best regards,
Sherif

[quoted text, click to view]
database for multilingual support i.e. Changing char/varchar/text fields to
nchar/nvarchar/ntext. Rest all other data types we can use as it is ex:
datetime, integers, floats, etc. The .NET runtime will take care of
displaying them in appropriate format depending on the culture info.
Secondly we don't have to code anything extra in C# to make this work expect
for displaying label and form identifiers from resource files depending upon
culture info. Now the big problem - You are saying as long as you use
parameterized query. Actually i am selecting/ inserting/updating data
from/to database by simply forming queries using stringbulider - like INSERT
INTO XYZ VALUES('X', 'Y'). This whole statement is executed using command
object. Same is the case with SELECT and UPDATE. So is this a problem??????
please help. Thanx in advance.
[quoted text, click to view]

AddThis Social Bookmark Button