473,385 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Display Unicode characters on Winforms

I'm getting data from a mySQL database (default char set = UTF-8).
I need to display data in Unicode but got only mongolian characters like
this: Phạm Thị Ngọc

I changed the textbox font to Arial Unicode MS but still not working.

Do I need conversion of data stored in mySQL database before displaying?
Thanks

Bill
Jul 19 '06 #1
6 5897
"Bill Nguyen" <bi*****************@jaco.comschrieb:
I'm getting data from a mySQL database (default char set = UTF-8).
I need to display data in Unicode but got only mongolian characters like
this: Phạm Thị Ngọc

I changed the textbox font to Arial Unicode MS but still not working.

Do I need conversion of data stored in mySQL database before displaying?
Windows Forms controls cannot directly convert the character entities like
'ạ' to the appropriate character. You may want to replace the string
"&#<number>;" with the value of 'ChrW(<number>)' or simply do not encode the
characters in the database using that way.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 19 '06 #2
Herfried;
I did not encode data. It must be part of the ISP procedure.
The text are displayed correctly with browsers, both IE and Firefox.
It's gonna be a big task trying the convert those <numberwith ChrW because
they are mixing with characters all over.

Bill

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:ed**************@TK2MSFTNGP03.phx.gbl...
"Bill Nguyen" <bi*****************@jaco.comschrieb:
>I'm getting data from a mySQL database (default char set = UTF-8).
I need to display data in Unicode but got only mongolian characters like
this: Phạm Thị Ngọc

I changed the textbox font to Arial Unicode MS but still not working.

Do I need conversion of data stored in mySQL database before displaying?

Windows Forms controls cannot directly convert the character entities like
'ạ' to the appropriate character. You may want to replace the
string "&#<number>;" with the value of 'ChrW(<number>)' or simply do not
encode the characters in the database using that way.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 19 '06 #3
Herfried;

I don't know if this will work, but I need help to try it:
here's sample of the text string

"Nghiên Cứu - Phê Bình"

I need to read each byte in the text string, then use chrW to convert it to
Unicode.

I tried chrW(ascW(textString)) but it only converts the 1st letter.

Is there a function to read all bytes in the text string in 1 pass?
Thanks

Bill

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:ed**************@TK2MSFTNGP03.phx.gbl...
"Bill Nguyen" <bi*****************@jaco.comschrieb:
>I'm getting data from a mySQL database (default char set = UTF-8).
I need to display data in Unicode but got only mongolian characters like
this: Phạm Thị Ngọc

I changed the textbox font to Arial Unicode MS but still not working.

Do I need conversion of data stored in mySQL database before displaying?

Windows Forms controls cannot directly convert the character entities like
'ạ' to the appropriate character. You may want to replace the
string "&#<number>;" with the value of 'ChrW(<number>)' or simply do not
encode the characters in the database using that way.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jul 19 '06 #4
Bill,
You could use a RegEx to convert the char escape codes to chars.

You could implement what Herfried suggested with something like:

Const input As String = "Nghiên Cứu - Phê Bình"

Const pattern As String = "\&\#\d{4}\;"
Static parser As New Regex(pattern, RegexOptions.Compiled)
Dim output As String = parser.Replace(input, AddressOf
MatchEvaluator)

Private Function MatchEvaluator(ByVal input As Match) As String
Dim value As String = input.Value.Substring(2, 4)
Return ChrW(CInt(value))
End Function
Does the 7913 represent a 4 digit decimal or hexidecimal number? You may
need to change the call to CInt accordingly...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Bill nguyen" <bi*****************@jaco.comwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
| Herfried;
|
| I don't know if this will work, but I need help to try it:
| here's sample of the text string
|
| "Nghiên Cứu - Phê Bình"
|
| I need to read each byte in the text string, then use chrW to convert it
to
| Unicode.
|
| I tried chrW(ascW(textString)) but it only converts the 1st letter.
|
| Is there a function to read all bytes in the text string in 1 pass?
| Thanks
|
| Bill
|
|
|
| "Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
| news:ed**************@TK2MSFTNGP03.phx.gbl...
| "Bill Nguyen" <bi*****************@jaco.comschrieb:
| >I'm getting data from a mySQL database (default char set = UTF-8).
| >I need to display data in Unicode but got only mongolian characters
like
| >this: Phạm Thị Ngọc
| >>
| >I changed the textbox font to Arial Unicode MS but still not working.
| >>
| >Do I need conversion of data stored in mySQL database before
displaying?
| >
| Windows Forms controls cannot directly convert the character entities
like
| 'ạ' to the appropriate character. You may want to replace the
| string "&#<number>;" with the value of 'ChrW(<number>)' or simply do not
| encode the characters in the database using that way.
| >
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
|
Jul 19 '06 #5
Jay;

If you look at the string again, you'll see that not only the 4-digit group
that needs to be translated but also other characters as well: (those in
squared brackets as below):

Nghi[ê]n Cứu - Ph[ê ]B[ì]nh

I'm using phpWebsite and mySQL database from an ISP (IpowerWeb.com).
Input text is Unicode when a webpage is created/updated.
The text string above is stored in mySQL table instead.
I gues I have to convert the text back to Unicode to view/edit then put it
back. mySQL probably converts the text to the above format by itself.

Any suggestion on how to accomplish this?

Thanks again

Bill
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.netwrote in
message news:OE**************@TK2MSFTNGP04.phx.gbl...
Bill,
You could use a RegEx to convert the char escape codes to chars.

You could implement what Herfried suggested with something like:

Const input As String = "Nghiên Cứu - Phê Bình"

Const pattern As String = "\&\#\d{4}\;"
Static parser As New Regex(pattern, RegexOptions.Compiled)
Dim output As String = parser.Replace(input, AddressOf
MatchEvaluator)

Private Function MatchEvaluator(ByVal input As Match) As String
Dim value As String = input.Value.Substring(2, 4)
Return ChrW(CInt(value))
End Function
Does the 7913 represent a 4 digit decimal or hexidecimal number? You may
need to change the call to CInt accordingly...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Bill nguyen" <bi*****************@jaco.comwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
| Herfried;
|
| I don't know if this will work, but I need help to try it:
| here's sample of the text string
|
| "Nghiên Cứu - Phê Bình"
|
| I need to read each byte in the text string, then use chrW to convert it
to
| Unicode.
|
| I tried chrW(ascW(textString)) but it only converts the 1st letter.
|
| Is there a function to read all bytes in the text string in 1 pass?
| Thanks
|
| Bill
|
|
|
| "Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
| news:ed**************@TK2MSFTNGP03.phx.gbl...
| "Bill Nguyen" <bi*****************@jaco.comschrieb:
| >I'm getting data from a mySQL database (default char set = UTF-8).
| >I need to display data in Unicode but got only mongolian characters
like
| >this: Phạm Thị Ngọc
| >>
| >I changed the textbox font to Arial Unicode MS but still not working.
| >>
| >Do I need conversion of data stored in mySQL database before
displaying?
| >
| Windows Forms controls cannot directly convert the character entities
like
| 'ạ' to the appropriate character. You may want to replace the
| string "&#<number>;" with the value of 'ChrW(<number>)' or simply do
not
| encode the characters in the database using that way.
| >
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
|


Jul 21 '06 #6
Bill,
I would extend the pattern to also match the square brackets also, then
modify the MatchEvaluator function to behave according to either the first
escape sequence or the second escape sequence...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Bill Nguyen" <bi*****************@jaco.comwrote in message
news:u%****************@TK2MSFTNGP04.phx.gbl...
| Jay;
|
| If you look at the string again, you'll see that not only the 4-digit
group
| that needs to be translated but also other characters as well: (those in
| squared brackets as below):
|
| Nghi[ê]n Cứu - Ph[ê ]B[ì]nh
|
| I'm using phpWebsite and mySQL database from an ISP (IpowerWeb.com).
| Input text is Unicode when a webpage is created/updated.
| The text string above is stored in mySQL table instead.
| I gues I have to convert the text back to Unicode to view/edit then put it
| back. mySQL probably converts the text to the above format by itself.
|
| Any suggestion on how to accomplish this?
|
| Thanks again
|
| Bill
|
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.netwrote in
| message news:OE**************@TK2MSFTNGP04.phx.gbl...
| Bill,
| You could use a RegEx to convert the char escape codes to chars.
| >
| You could implement what Herfried suggested with something like:
| >
| Const input As String = "Nghiên Cứu - Phê Bình"
| >
| Const pattern As String = "\&\#\d{4}\;"
| Static parser As New Regex(pattern, RegexOptions.Compiled)
| Dim output As String = parser.Replace(input, AddressOf
| MatchEvaluator)
| >
| Private Function MatchEvaluator(ByVal input As Match) As String
| Dim value As String = input.Value.Substring(2, 4)
| Return ChrW(CInt(value))
| End Function
| >
| >
| Does the 7913 represent a 4 digit decimal or hexidecimal number? You may
| need to change the call to CInt accordingly...
| >
| --
| Hope this helps
| Jay B. Harlow [MVP - Outlook]
| .NET Application Architect, Enthusiast, & Evangelist
| T.S. Bradley - http://www.tsbradley.net
| >
| >
| "Bill nguyen" <bi*****************@jaco.comwrote in message
| news:eU**************@TK2MSFTNGP03.phx.gbl...
| | Herfried;
| |
| | I don't know if this will work, but I need help to try it:
| | here's sample of the text string
| |
| | "Nghiên Cứu - Phê Bình"
| |
| | I need to read each byte in the text string, then use chrW to convert
it
| to
| | Unicode.
| |
| | I tried chrW(ascW(textString)) but it only converts the 1st letter.
| |
| | Is there a function to read all bytes in the text string in 1 pass?
| | Thanks
| |
| | Bill
| |
| |
| |
| | "Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
| | news:ed**************@TK2MSFTNGP03.phx.gbl...
| | "Bill Nguyen" <bi*****************@jaco.comschrieb:
| | >I'm getting data from a mySQL database (default char set = UTF-8).
| | >I need to display data in Unicode but got only mongolian characters
| like
| | >this: Phạm Thị Ngọc
| | >>
| | >I changed the textbox font to Arial Unicode MS but still not
working.
| | >>
| | >Do I need conversion of data stored in mySQL database before
| displaying?
| | >
| | Windows Forms controls cannot directly convert the character
entities
| like
| | 'ạ' to the appropriate character. You may want to replace the
| | string "&#<number>;" with the value of 'ChrW(<number>)' or simply do
| not
| | encode the characters in the database using that way.
| | >
| | --
| | M S Herfried K. Wagner
| | M V P <URL:http://dotnet.mvps.org/>
| | V B <URL:http://classicvb.org/petition/>
| |
| |
| >
| >
|
|
Jul 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ali | last post by:
I was wondering how one would go about displaying unicode in a Label object in a Tkinter window. I am trying to display text in another language. Please help.
76
by: Zenobia | last post by:
How do I display character 151 (long hyphen) in XHTML (utf-8) ? Is there another character that will substitute? The W3C validation parser, http://validator.w3.org, tells me that this character...
4
by: SB | last post by:
Hi, I'd like to display some non-ascii characters in a DOS window. I'm getting the characters from Windows Character Map, such as the Spade (U+2660) and a few others. However, I can't get it to...
1
by: Daman | last post by:
Hi, I am currently facing difficulty displaying chinese, japanese, russian etc. characters. I am using VB 6 and ADO to query the DB2 Version 7.2 unicode database (UTF-8). The resultset that...
3
by: Jennifer | last post by:
Hi, Is there anyone to have idea how to make the MFC CDialog box display Unicode (like Chinese characters) in .NET 2005? We have some dilog boxes created from CDialog class in VC++ 6.0 and try...
6
by: Melissa | last post by:
Initially the form is loaded using ASP and HTML and the ü codes display the characters correctly. I have the values stored in a javascript array so that I can more easily and dynamically change...
8
by: Andy | last post by:
Hello All: I have a windows application that I need to encode a string using Unicode. The example I have been given to use is a Web-Version. Below is the webcode. ...
1
by: jackbenimble999 | last post by:
Hello! What is the best way to display a EUC-encoded field with Access 2007? Or, failing that, how do you display a Unicode field as the character instead of the number? Do I need to use a...
6
vekipeki
by: vekipeki | last post by:
I am having a problem with basic drawing of unicode characters in Windows 2000 and XP. I have written a simplest possible C# WinForms program to test it (just create a new Windows Forms C#...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.