homepage Welcome to WebmasterWorld Guest from 54.198.135.17
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Circle "R"'s are Driving Me Crazy
Circle "R"'s are Driving Me Crazy
exit44




msg:4098489
 3:01 am on Mar 16, 2010 (gmt 0)

I'm using php/mysql and the circle 'r' character (®) looks like it is supposed to in the DB.... just like a registered trademark symbol. But, when I print it out to an HTML page I get the funny looking question mark character.

Does anyone know how to fix this?

 

tangor




msg:4098492
 3:07 am on Mar 16, 2010 (gmt 0)

Make sure your doc type embraces the character set.

exit44




msg:4098493
 3:10 am on Mar 16, 2010 (gmt 0)

I have used htmlentities() and html_entity_decode() to try to fix it but it doesn't seem to be working. I'm using UTF-8 in those functions and I have UTF-8 set on the doc-type, too.

claus




msg:4098494
 3:15 am on Mar 16, 2010 (gmt 0)

Is your DB table set to UTF-8 as well?

exit44




msg:4098496
 3:18 am on Mar 16, 2010 (gmt 0)

The db table is set to utf8_sweedish_ci. There was not just a "utf-8" selection for this. Which one should I choose?

claus




msg:4098497
 3:23 am on Mar 16, 2010 (gmt 0)

I believe the right one is utf8_general_ci

If this doesn't solve your problem, I have no idea what the cause is ;-)

exit44




msg:4098503
 3:34 am on Mar 16, 2010 (gmt 0)

Dang. That didn't solve it. How do you handle clients copy/pasting the circle "r" character into web forms?

Ahkamden




msg:4098507
 3:36 am on Mar 16, 2010 (gmt 0)

Escape the characters they try to put in.

If registered is that big, can you make it a checkbox, if checked when it's displayed you'll show the ASCII?

exit44




msg:4098509
 3:41 am on Mar 16, 2010 (gmt 0)

They want to put it into the middle of a character string, though. How do you handle that?

tangor




msg:4098514
 3:58 am on Mar 16, 2010 (gmt 0)

search for the expected character(s), strip it, then put the proper character back in. More work, of course!

claus




msg:4098556
 5:13 am on Mar 16, 2010 (gmt 0)

Of course, that's it. Users copy-paste from a wrong character set. Didn't think about that.

Here's a quick regular expression that will take care of that for you:

s/\u00AE/®/

\u00AE is the "circle r"
® is the corresponding HTML entity ( = ® )

I'm not sure if you use PHP/ASP/Perl/whatever, but I'm sure your programming language of choice has some way to implement a RegExp

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved