replace ë by e

trouble2

Member
Joined
Jan 30, 2009
Messages
7
Programming Experience
1-3
This is strange, I thought this always worked, but now it doesn't anymore.
Does anyone know????

strText = strText.Replace("ë", "e")

It does work with normal characters, but not with stuff like ë, é, à, ú, etc.
 
Have you checked that the character you're specifying you want replaced is the actual character that is in the string? By that I mean have you checked their Unicode point value?
 
Have you heard of ASCII and/or Unicode? They are character sets that assign a numerical value to each character in the set. When text is stored in binary form it is stored as these numerical values. I'm saying that you may think that you're specifying a particular character but if it doesn't have the same numerical value as the character in your text then it's not the same character. Test the numerical values of the characters in your text and see if they are what you think they are.
 
I made this thing using a simple asp:textbox which stores the text in a MS SQL table.
When I look at the table I can see stuf like: ëên, áán, etc.
Seems a hard problem, when I search google there are a lot of people trying to find an answer, but I didn't find one yet....

I'm simply trying to find a function which will replace characters like ë, é, è to e and â, á, à to a, etc..
It looked like a simple thing, but apparently it's not.
 
Function ReplaceAccentedChars(ByVal input As String) As String
input = input.Replace("À", "A")
input = input.Replace("Á", "A")
input = input.Replace("Â", "A")
input = input.Replace("Ã", "A")
input = input.Replace("Ä", "A")
input = input.Replace("â", "a")
input = input.Replace("ã", "a")
input = input.Replace("ä", "a")
input = input.Replace("à", "a'")
input = input.Replace("á", "a'")

input = input.Replace("È", "E'")
input = input.Replace("É", "E'")
input = input.Replace("Ê", "E")
input = input.Replace("Ë", "E")
input = input.Replace("ê", "e")
input = input.Replace("ë", "e")
input = input.Replace("è", "e'")
input = input.Replace("é", "e'")

input = input.Replace("Ì", "I")
input = input.Replace("Í", "I")
input = input.Replace("Î", "I")
input = input.Replace("Ï", "I")
input = input.Replace("î", "i")
input = input.Replace("ï", "i")
input = input.Replace("ì", "i'")
input = input.Replace("í", "i'")

input = input.Replace("Ò", "O")
input = input.Replace("Ó", "O")
input = input.Replace("Ô", "O")
input = input.Replace("Õ", "O")
input = input.Replace("Ö", "O")
input = input.Replace("ô", "o")
input = input.Replace("õ", "o")
input = input.Replace("ö", "o")
input = input.Replace("ò", "o'")
input = input.Replace("ó", "o'")

input = input.Replace("Ù", "U")
input = input.Replace("Ú", "U")
input = input.Replace("Û", "U")
input = input.Replace("Ü", "U")
input = input.Replace("û", "u")
input = input.Replace("ü", "u")
input = input.Replace("ù", "u'")
input = input.Replace("ú", "u'")

input = input.Replace("Ý", "Y")
input = input.Replace("ý", "y")
input = input.Replace("ñ", "n")

Return input
End Function

didn't work,

however input = input.Replace("a", "n") does work, so it seems the special characters can't be found...
 
Thanks, I'll try...
But if this is the solution how would you go about making a general function for this like for äÄáÁéËúÚ.

I mean, I can think of something, but I thought isn't there already someone who has made something like this.
 
Got this from somewhere:
Public Shared Function CleanSpecialChars(ByVal UnMot As String) As String
UnMot = Replace(UnMot, Chr(138), "S")
UnMot = Replace(UnMot, Chr(142), "Z")
UnMot = Replace(UnMot, Chr(158), "z")
UnMot = Replace(UnMot, Chr(159), "Y")
UnMot = Replace(UnMot, Chr(192), "A")
UnMot = Replace(UnMot, Chr(193), "A")
UnMot = Replace(UnMot, Chr(194), "A")
UnMot = Replace(UnMot, Chr(195), "A")
UnMot = Replace(UnMot, Chr(196), "A")
UnMot = Replace(UnMot, Chr(197), "A")
UnMot = Replace(UnMot, Chr(200), "E")
UnMot = Replace(UnMot, Chr(201), "E")
UnMot = Replace(UnMot, Chr(202), "E")
UnMot = Replace(UnMot, Chr(203), "E")
UnMot = Replace(UnMot, Chr(204), "I")
UnMot = Replace(UnMot, Chr(205), "I")
UnMot = Replace(UnMot, Chr(206), "I")
UnMot = Replace(UnMot, Chr(207), "I")
UnMot = Replace(UnMot, Chr(208), "D")
UnMot = Replace(UnMot, Chr(209), "N")
UnMot = Replace(UnMot, Chr(210), "O")
UnMot = Replace(UnMot, Chr(211), "O")
UnMot = Replace(UnMot, Chr(212), "O")
UnMot = Replace(UnMot, Chr(213), "O")
UnMot = Replace(UnMot, Chr(214), "O")
UnMot = Replace(UnMot, Chr(217), "U")
UnMot = Replace(UnMot, Chr(218), "U")
UnMot = Replace(UnMot, Chr(219), "U")
UnMot = Replace(UnMot, Chr(220), "U")
UnMot = Replace(UnMot, Chr(221), "Z")
UnMot = Replace(UnMot, Chr(224), "a")
UnMot = Replace(UnMot, Chr(225), "a")
UnMot = Replace(UnMot, Chr(226), "a")
UnMot = Replace(UnMot, Chr(227), "a")
UnMot = Replace(UnMot, Chr(228), "a")
UnMot = Replace(UnMot, Chr(229), "a")
UnMot = Replace(UnMot, Chr(231), "c")
UnMot = Replace(UnMot, Chr(232), "e")
UnMot = Replace(UnMot, Chr(233), "e")
UnMot = Replace(UnMot, Chr(234), "e")
UnMot = Replace(UnMot, Chr(235), "e")
UnMot = Replace(UnMot, Chr(236), "i")
UnMot = Replace(UnMot, Chr(237), "i")
UnMot = Replace(UnMot, Chr(238), "i")
UnMot = Replace(UnMot, Chr(239), "i")
UnMot = Replace(UnMot, Chr(241), "n")
UnMot = Replace(UnMot, Chr(242), "o")
UnMot = Replace(UnMot, Chr(243), "o")
UnMot = Replace(UnMot, Chr(244), "o")
UnMot = Replace(UnMot, Chr(245), "o")
UnMot = Replace(UnMot, Chr(246), "o")
UnMot = Replace(UnMot, Chr(249), "u")
UnMot = Replace(UnMot, Chr(250), "u")
UnMot = Replace(UnMot, Chr(251), "u")
UnMot = Replace(UnMot, Chr(252), "u")
UnMot = Replace(UnMot, Chr(253), "y")
UnMot = Replace(UnMot, Chr(255), "y")
Return CStr(UnMot)
End Function


Isn't there any better method you think?
 
Back
Top