deansatch Posted September 8, 2011 Share Posted September 8, 2011 I am busy translating a site into chinese and one part which uses SUBSTRING_INDEX(CONTENT, ' ', 16) AS CONTENT doesn't seem to be working as expected. It works on the English version but it shows everything in the Chinese version. Do I need to tell MYSQL that its using chinese characters or something? Quote Link to comment Share on other sites More sharing options...
deansatch Posted September 8, 2011 Author Share Posted September 8, 2011 Ah. It's because there are no spaces between the characters/words/paragraphs. I tried LEFT(CONTENT, 100) AS CONTENT which works but sometimes the last character is the dreaded diamond with a question mark in it. Any ideas??? Quote Link to comment Share on other sites More sharing options...
deansatch Posted September 8, 2011 Author Share Posted September 8, 2011 Arrgh! The text is going into my database as chinese characters and coming out as chinese characters..but in phpmyadmin it looks like a load of gibberish surrounded by html tags. Clearly i am missing something vital here Quote Link to comment Share on other sites More sharing options...
deansatch Posted September 8, 2011 Author Share Posted September 8, 2011 Ok...I am now assuming that LEFT() is producing a [?] symbol because it is counting the number of characters in the database and because several symbols make up a chinese character, it is making the last one a half-done, none-recognisable thing. So...is the fact the data is stored in mysql random looking symbols correct? And if so, how can I use functions like LEFT()? Quote Link to comment Share on other sites More sharing options...
fenway Posted September 8, 2011 Share Posted September 8, 2011 Chinese is likely being stored as multi-byte characters -- either 2 or 3 -- and if it's 3, 100 won't work. At least pick a number that's a multiple of both 2 and 3. Quote Link to comment Share on other sites More sharing options...
deansatch Posted September 8, 2011 Author Share Posted September 8, 2011 Ah..thanks. I kept ploughing through it and eventually used mb_substr() in php instead. Not ideal, but it works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.