This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Showing special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Showing special characters" Watch "Showing special characters" New topic
Author

Showing special characters

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Ok on the server side if I print the result of my query, the little special symbols (^tm and the little circle with an "R" in it, and the copyright symbol) show up.

But when I get the result with AJAX and put it in a div, the "special symbols" are replaced by boxes.

Is there a way I can fix this?

Thanks,

Justin Fox
[ January 27, 2008: Message edited by: Bear Bibeault ]

You down with OOP? Yeah you know me!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56528
    
  14

You should be using HTML entities for the special symbols. ™ for ™ and ® for ®.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Ok, but the thing is, the text is stored in a database on the server, I'm just doing a select statement and returning the recordset in an echo format and then retrieving that echo with AJAX. how do I convert the boxes to what they need to be If all they are when they get to the xmlHttp.responseText are boxes.

Justin Fox
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56528
    
  14

Your best bet is to perform a text substitution on the server before sending the text off as the response.
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Thats what I was kind of thinking.

maybe like //trade and //reg and //copy

for the different symbols

Justin Fox
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56528
    
  14

?
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
good "?", because that didnt work.

I tried to replace all the '™' with //trade, and '®' with //reg and so on.

but it doesn't work.

so I'm pretty much lost...

Justin Fox
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56528
    
  14

After reading the string from the DB just perform a string replacement swapping the special chars (you'll need to lookup or figure out their values) with the HTML entities. I'm not sure what left field //trade came out of.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Showing special characters
 
Similar Threads
Why a legal identifier cannot include the character #
generics compilation...
displaying symbols & spl char in applet
generate unique fixed length code from a string
what is gt??