How do I deal with ý - ù and so on?

Discussion in 'PHP' started by mahmood, Jan 23, 2007.

  1. #1
    I use a script to import data from Excel to mysql. For a long time I have had problems with strange characters such as ù which must be ù or ý which must be ý and so on.

    At the moment I replace every single character that I found with the correct one but this is not an efficient way, is there a generic solution to this problem?
     
    mahmood, Jan 23, 2007 IP
  2. lmoss

    lmoss Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    These look like UTF-8 characters. Could it be that your Excel file uses a UTF-8 character encoding while your database uses a ISO-8859-1 character encoding? If that's the case, you would need either to change the encoding of your Excel file or of your database, or you would need to change your script so that it does the conversion. (If your script is in PHP, you can use the function iconv() for that purpose.)
     
    lmoss, Jan 27, 2007 IP
  3. mahmood

    mahmood Guest

    Messages:
    1,228
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply.

    How do I change the character set of excel file to UTF-8?
     
    mahmood, Jan 29, 2007 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    There is a program I used a while ago (windows based) that does the transfer and it was pretty easy.

    If you are talking about a script, you can use a function called iconv to convert characters from and to.

    Peace,
     
    Barti1987, Jan 29, 2007 IP
  5. mahmood

    mahmood Guest

    Messages:
    1,228
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #5
    In order to use iconv I need to know the original character set of the excel file. How do I find it?
     
    mahmood, Jan 30, 2007 IP
  6. lmoss

    lmoss Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It seems that your Excel file is in UTF-8 while your MySQL database is probably in ISO-8859-1. If you do iconv() UTF-8 --> ISO-8859-1 on your Excel data prior to importing it in MySQL, does it solve the problem?
     
    lmoss, Jan 30, 2007 IP