If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySql function for replacing non ascii chars

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-05-08, 10:52
gwgeller gwgeller is offline
Registered User
 
Join Date: Jan 2004
Posts: 145
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.")
Reply With Quote
  #2 (permalink)  
Old 09-05-08, 11:06
gwgeller gwgeller is offline
Registered User
 
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.")
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On