Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    145

    Unanswered: MySql function for replacing non ascii chars

    Hello,
    I have created a function in mysql 5.0.45 using sqlyog that replaces certain characters like ' and '' with html entities. The function is called from a stored proc. We import data from sql server 2000 into mysql. The data is then displayed using ruby on rails(ror).

    ror can't display all the characters in some of our text (varchar) fields, which is the reason for the function. It displays a ? with a diamond around it for characters like ' or ''.

    In sqlyog if I use the actual characters in the REPLACE function everything is fine. When I run the function from the mysql command prompt the function doesn't work, none of the characters get replaced. I tried using CHAR() instead of the actual characters and I thought it worked, but some of the characters are considered equal when using the CHAR() function. For instance CHAR(226) will replace both and , which isn't good.

    So it looks to be a character set issue. Can I tell the function to use a different character set than the db default? Or is there another method I could be using to recognize these characters?

    Thanks,
    GG
    Code:
    On Error Goto Hell
    
    Hell:
        Msgbox("An error occurred, but was sent to Hell. You may continue.")

  2. #2
    Join Date
    Jan 2004
    Posts
    145
    I figured it out. In my stored proc I specified the char set to use with this command:

    SET NAMES 'utf8'
    GG
    Code:
    On Error Goto Hell
    
    Hell:
        Msgbox("An error occurred, but was sent to Hell. You may continue.")

Posting Permissions

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