SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast ptolemy's Avatar
    Join Date
    Feb 2002
    Location
    Geneva, Switzerland
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Accented characters in MySQL

    I'm using a textarea for element to send user data to my MySQL database. I'm having problems when the user enters characters with accents though. The site is in French so there's no way I can work without using accents. I would imagine MySQL could handle all ASCII characters but maybe I'm mistaken. The weird thing is that an '' turns into an '' when inserted from my form. It seems as though the ASCII table (for accesnted characters at least) is shifted in MySQL.

    Any idea what's going on?

    -ptolemy

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)

    ascii

    I would imagine MySQL could handle all ASCII characters but maybe I'm mistaken. The weird thing is that an '' turns into an '' when inserted from my form.
    when the '' is entered, it should go in as ascii 233 -- try
    Code:
    select char(ascii('')) from onerow
    (where onerow is like oracle's DUAL table)

    if your accented characters get stored properly but don't come out right, it's a problem with the character set being used for display

    is this on an html page, or...?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast ptolemy's Avatar
    Join Date
    Feb 2002
    Location
    Geneva, Switzerland
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice, I'll give it a try at work tomorrow. By the way, I'm writing the information in an HTML form and the data eventually gets called into a dynamic text box in Flash.

    -ptolemy

  4. #4
    SitePoint Enthusiast ptolemy's Avatar
    Join Date
    Feb 2002
    Location
    Geneva, Switzerland
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've successfully converted accented characters from my HTML form using str_replace(). Things are working now but I must admit that this is a rather clumsy method, especially when I must convert every possible (upper and lower case) accented character used in the French language.

    There is obviously a difference in the text encoding model of my document and that of the MySQL database. I've tried using different HTML encoding types but to no avail. I've also tried some of PHPs encoding functions but they didn't do the trick either.

    Any help would be appreciated
    -ptolemy

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    There is obviously a difference in the text encoding model of my document and that of the MySQL database.
    hmmm, you didn't say whether the is actually stored as 233 in your database -- if it's coming in from an html form input field or textarea, then unless you change it, then should definitely go into the database correctly as 233

    you also mention that you've tried different HTML encoding types -- is this page on the web where we can look at it?

    i'm afraid i cannot help with the php functions, though

    rudy

  6. #6
    SitePoint Enthusiast ptolemy's Avatar
    Join Date
    Feb 2002
    Location
    Geneva, Switzerland
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The is input on the form as 233 but is displayed in the database as . I can manually enter (via DOS) an using 133. I really don't know why there is a difference.

    This isnt on the web at the moment, I'm currently testing offline...

    -ptolemy

  7. #7
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you are going to get really tired of me saying this, but the character is not "displayed in the database" -- the database by itself is incapable of displaying anything

    characters are stored in the database as ascii codes (bit strings, really), and displayed by some kind of software, whether that's php writing a web page, or phpmyadmin, or whatever

    probably it was a typo when you said that you entered 133, because that's the ellipsis character()

    did you try the select char(ascii('')) trick yet?

    it's interesting that you are getting , because that's 249 which is 16 higher than 233, and 16 is an interesting number in binary arithmetic...

    i think you should first establish with certainty what your characters are being stored as -- something is going on, and it's gotta be either on input or on output
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •