Reputation: 851
I have an international photo website. When the office uploads photos that have come from abroad, the captions and headlines sometimes have foreign characters, such as:
1. François Hollande
2. ValŽrie Trierweiler
And these get stored in the database (MySQL – latin1_swedish_ci), as-is. Now, when it comes to searching for Francois, without the French characters, in plain English, those particular photos do not display.
Now this isn't just a problem with French characters – it's other countries too. How is this possible, before I submit to my database, to convert these foreign characters to normal ones, like:
Upvotes: 2
Views: 2182
Reputation: 786
And like this it can be a function
Function unaccent(strg)
With Server.CreateObject("Adodb.Stream")
.Charset = "ascii"
.Open
.WriteText strg
.Position = 0
unaccent = .ReadText
End With
End Function
Upvotes: 1
Reputation: 16950
You can do it using Adodb.Stream
with ascii
charset. Here is an example:
With Server.CreateObject("Adodb.Stream")
.Charset = "ascii"
.Open
.WriteText "François Hollande ValŽrie Trierweiler ÖÇŞİĞÜöçşığü ôûõòùìñ"
.Position = 0
Response.Write .ReadText
End With
Above script must print Francois Hollande ValZrie Trierweiler OCSIGUocsigu ouoouin
exactly.
Upvotes: 5
Reputation: 2510
This answer will most probably cover your case.
You don't need an external library, and you can check for conformance using a numerous of methods, using regexes being my personal preference for not too large strings.
Upvotes: 0