Forum Moderators: open

Message Too Old, No Replies

Javascript and Chinese Characters . . .

They don't like each other . . .

         

roddy

2:18 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



Ok, I'll take this slowly to make sure I get it right.

I have a forum, phpBB running on a mysql database. Due to the nature of the forum we have a fair number of posts that use Chinese Characters. Occasionally they didn't display properly, but since a recent switch to UTF-8 encoding, they've all been fine.

I have a 'topics anywhere' modification added. This allows me to produce a piece of javascript, which I then place in another, off-site page, or give to someone else.

Everytime this javascript is run, it runs a (php) script hosted on my server, which queries the database and passes back a list of the latest topics - which are printed to the page in question. This acts as a good advert for my site, and a little bit of free dynamic content for the guy or gal hosting it.

However, when the topic titles are printed, any Chinese Characters do NOT display properly.

This is not a problem with my forum - we have no trouble with the same titles. It's not a problem with the pages in question, as other Chinese characters display fine, and I've tried switching the encoding around.

So, I've concluded that the javascript does not like Chinese characters.

Any idea on how I could solve this without having to redo the whole system to not use js? I've done the usual searches, but with no joy.

Roddy

SethCall

5:15 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



You can print out Chinese characters in javascript using javascripts support for unicode

A unicode character looks like: \u#####

And so... I haven't converted from utf-8 to unicode ever, but what you will have to figure out is what the unicode representation of each character you are trying to print is.

UTF-8 is a transformation of unicode, so it should be rather straightfoward, if not requiring a bit of research.

Am I on the riht track with what you are looking for? I'm not sure.

roddy

11:28 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



Thanks for the answer - I thought this one would slip down the board unnoticed, given the obscurity of Chinese Characters and the unpopularity of Javascript.

I don't think a manual solution will work. As the output of the script changes according to what the most recent topics are, I can't predict what characters will be needed.

I'd really like to find a solution for this, as the random garbage thrown up occasionally is causing people to take the scripts off their sites (understandably), which results in me losing great links . . .

Roddy

SethCall

11:36 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



You shouldn't have to know what characters are being used before hand... (at least, not how I envision this)

Perhaps you coudl give a javascript code snippet of whats cuasing the problem?

Jenstar

12:14 am on Oct 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you post about this on the mod support boards at phpbb.com? I use this mod myself, and there is a support thread just for this mod. Try posting there, and you will hopefully get a specific answer for this - I noticed there have been queries there on other language issues with the topics anywhere mod there.