473,739 Members | 6,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5986
"Bill Nguyen" <bi************ *****@jaco.coms chrieb:
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******** ******@TK2MSFTN GP03.phx.gbl...
"Bill Nguyen" <bi************ *****@jaco.coms chrieb:
>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(textS tring)) 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******** ******@TK2MSFTN GP03.phx.gbl...
"Bill Nguyen" <bi************ *****@jaco.coms chrieb:
>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.Co mpiled)
Dim output As String = parser.Replace( input, AddressOf
MatchEvaluator)

Private Function MatchEvaluator( ByVal input As Match) As String
Dim value As String = input.Value.Sub string(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.comw rote in message
news:eU******** ******@TK2MSFTN GP03.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(textS tring)) 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******** ******@TK2MSFTN GP03.phx.gbl...
| "Bill Nguyen" <bi************ *****@jaco.coms chrieb:
| >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.netw rote in
message news:OE******** ******@TK2MSFTN GP04.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.Co mpiled)
Dim output As String = parser.Replace( input, AddressOf
MatchEvaluator)

Private Function MatchEvaluator( ByVal input As Match) As String
Dim value As String = input.Value.Sub string(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.comw rote in message
news:eU******** ******@TK2MSFTN GP03.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(textS tring)) 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******** ******@TK2MSFTN GP03.phx.gbl...
| "Bill Nguyen" <bi************ *****@jaco.coms chrieb:
| >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.comw rote in message
news:u%******** ********@TK2MSF TNGP04.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.netw rote in
| message news:OE******** ******@TK2MSFTN GP04.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.Co mpiled)
| Dim output As String = parser.Replace( input, AddressOf
| MatchEvaluator)
| >
| Private Function MatchEvaluator( ByVal input As Match) As String
| Dim value As String = input.Value.Sub string(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.comw rote in message
| news:eU******** ******@TK2MSFTN GP03.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(textS tring)) 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******** ******@TK2MSFTN GP03.phx.gbl...
| | "Bill Nguyen" <bi************ *****@jaco.coms chrieb:
| | >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
10621
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
15144
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 and the ones around it are illegal - then, after resubmission it flags no errors. So, are there any illegal characters between 0 and 255 in the UTF-8 character set or is it just my imagination that the W3C validation parser thinks there are -...
4
3082
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 work. I know the characters I'm trying to display are Unicode and that is presenting the problem. Does anyone know how to do this if even possible? Thanks!
1
7558
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 comes back contains garbage characters for Chinese, Russian etc languages. The english characters come back fine using ADO. It seems that DB2 assumes that my application is NOT Unicode compliant.
3
5435
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 to integrate them into our new project developed in .NET 2005 to display Unicode. Any idea and hint will be greatly appreciated. Thank you in advance. Jennifer
6
3847
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 the state/region dropdown when the country changes. However, when my javascript code tries to add the new option and print out new region the literal value such as "Würrtemberg" is displayed instead of the special character. Can this be done in...
8
8497
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. Response.ContentEncoding=System.Text.Encoding.Unicode; Response.ContentType = "application/postscript"; Response.Buffer =true; Response.AppendHeader("Content-Disposition","attachment; filename=\"" + sFilename + "\"");
1
2645
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 browser control? I have created a local web page which successfully displays a Unicode character when I bring it up using a standard browser, but so far I haven't been able to figure out how to get the WebBrowser control to navigate to the page - it...
6
10712
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# application and add a Paint event handler): public partial class Form1 : Form { public Form1() { InitializeComponent();
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9479
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6054
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.