2

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:

  1. Francois Hollande
ShadowStorm
  • 853
  • 4
  • 10
  • 23
  • There is a PHP module named translit http://pecl.php.net/package/translit, perhaps you can get inspiration from there. – wroniasty Sep 18 '12 at 15:54

3 Answers3

5

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.

Kul-Tigin
  • 16,728
  • 1
  • 35
  • 64
1

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
George SEDRA
  • 796
  • 8
  • 11
0

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.

Community
  • 1
  • 1
Mihalis Bagos
  • 2,500
  • 1
  • 22
  • 32