Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

Translate accented characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JezB - 09 May 2005 13:05 GMT
Is there anything in the framework which will help translate accented
characters in strings to their standard counterparts?

eg. "Gráda" to "Grada"
Mark Rae - 09 May 2005 13:44 GMT
> Is there anything in the framework which will help translate accented
> characters in strings to their standard counterparts?
>
> eg. "Gráda" to "Grada"

Interestingly enough, I was looking for exactly the same thing recently, and
was unable to find anything native to the Framework, so I ended up writing
my own mapping function. Easy enough for the Latin languages (e.g. French,
Spanish, Italian, Portuguese etc), fairly simply for German (e.g. any vowel
with an umlaut is replaced by the unmodified vowel + 'e'), a little messier
for the Scandinavian languages, even worse for Greek and Cyrillic, and
almost impossible for the Eastern European languages with diacritics.

What is the business purpose behind your need to do this, AAMOI?
JezB - 09 May 2005 13:52 GMT
I'm passing artist/album names stored within mp3 files through Amazon's web
service, to look up album details. Many of the artist names have accented
characters, since I am interested in world/celtic music, but Amazon's serach
criteria seems to be based on normalized unaccented strings. A real pain to
edit all my id3 tags !

>> Is there anything in the framework which will help translate accented
>> characters in strings to their standard counterparts?
[quoted text clipped - 11 lines]
>
> What is the business purpose behind your need to do this, AAMOI?
Morten Wennevik - 09 May 2005 14:33 GMT
Hi Jez,

There is nothing pre-made in .Net that will do what you want.  You need to create a translation table and translate each character as necessary.

There is a method that seems to work in most cases involving translation between different encodings, but I cannot guarantee that it works in all cases.

string s = "áàäãâåéèëêíìïîóòöõôøúùüûýÿ";
byte[] b = Encoding.GetEncoding(1251).GetBytes(s);
string t = Encoding.ASCII.GetString(b);

//t == aaaaaaeeeeiiiioooooouuuuyy

Signature

Happy coding!
Morten Wennevik [C# MVP]

Mark Rae - 09 May 2005 14:57 GMT
> There is a method that seems to work in most cases involving translation
> between different encodings, but I cannot guarantee that it works in all
[quoted text clipped - 5 lines]
>
> //t == aaaaaaeeeeiiiioooooouuuuyy

No use at all for German:

ä = ae
ö = oe
ü = ue
ß = ss
JezB - 09 May 2005 15:05 GMT
That's good enough for me !!! This is just a hobby program so doesn't need
to be foolproof.
Many thanks Morten

> Hi Jez,
>
[quoted text clipped - 10 lines]
>
> //t == aaaaaaeeeeiiiioooooouuuuyy
Mark Rae - 09 May 2005 15:02 GMT
> I'm passing artist/album names stored within mp3 files through Amazon's
> web service, to look up album details. Many of the artist names have
> accented characters, since I am interested in world/celtic music, but
> Amazon's serach criteria seems to be based on normalized unaccented
> strings. A real pain to edit all my id3 tags !

Then the translation table approach is what you need here...
Ignacio Machin \( .NET/ C# MVP \) - 09 May 2005 14:26 GMT
Hi,

There is nothing like this in the framework, what you can do is use
String.Replace , it will be slower but there are only 5 vocals after all :)

Cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

> Is there anything in the framework which will help translate accented
> characters in strings to their standard counterparts?
>
> eg. "Gráda" to "Grada"
Mark Rae - 09 May 2005 15:00 GMT
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote

> There is nothing like this in the framework, what you can do is use
> String.Replace , it will be slower but there are only 5 vocals after all
> :)

If by "vocals" you mean "vowels", then that just isn't the case in many
languages...
Ignacio Machin \( .NET/ C# MVP \) - 09 May 2005 18:47 GMT
Hi,

Yes I meant vowels :)

It was an "spanglish" vocales = vowels  in spanish :)

You are right, but in a particular language there are not that many, most
certainly by the description of the OP he has the mp3 tags in one language

cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
> wrote in message news:%23a82wqJVFHA.3252@TK2MSFTNGP10.phx.gbl...
[quoted text clipped - 5 lines]
> If by "vocals" you mean "vowels", then that just isn't the case in many
> languages...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.