Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I change the character set of a string

Status
Not open for further replies.

rambleon

Programmer
Mar 6, 2004
130
IL
Hi I need some code for changing text in a string(or file) from one character set to another (old code to new code) would the following work

Regex.Replace(String, [a-z], [A-Z])
 
If you mean how do you change the case of a string - then you could use something like:

Dim s1 As String
Dim s2 As String

s1 = "This is a test string with symbols and numbers (456)"
s2 = s1.ToUpper

MessageBox.Show(s2)


This will display:

THIS IS A TEST STRING WITH SYMBOLS AND NUMBERS (456)

Hope this helps.

[vampire][bat]
 
No I actualy want to transform the character set from Hebrew DOS code to Hebrew Windows code. The code was just for the format [a-z] = old dos character set, [A-Z] = new windows character set.

Regex.Replace(String, [a-z], [A-Z])
 
Hrm.

s1 = "This is a test string with symbols and numbers (456)".toupper

will do the same thing as

regex.replace(s1, "[a-z]", "[A-Z]")

ASCII value whys. I'm not familiar with Hebrew, but if it follows ASCII standard, then that should work fine. If not, I think there is an encoder namespace (or something like that) that allows you to change an ASCII string to a Unicode string.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I would look at calling Encoding.GetEncoding(862) to get a Hebrew specific Encoding obect. You then call GetBytes on your Hebrew string, which gets you the byte equivalent of your string. Now you can call Encoding.Convert() to change the byte array from the Hebrew encoding to Unicode (which is what the .NET framework uses).
Code:
Dim myHebrewEncoding As Encoding 
Dim myHewbrewBytes as Byte()
Dim myUnicodeHebrewBytes as Byte()
Dim myUnicodeHebrewString as String

myHebrewEncoding = Encoding.GetEncoding(862)
myHebrewBytes = myHebrewEncoding.GetBytes(my862codePageString)
myUnicodeHewbrewBytes = Encoding.Convert(myHebrewEncoding, Encoding.Unicode, myHebrewBytes)
myUnicodeHebrewstring = Encoding.GetString(myUnicodeHewbrewBytes)
Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top