473,287 Members | 1,570 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,287 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 5888
"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#...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.