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

PHP Server Side Scripting Forum

    
swedish characters and htmlspecialchars etc
helenp




msg:4640472
 9:58 am on Jan 27, 2014 (gmt 0)

Hi,
My database is latin1_swedish_ci
so in the mysql conection I set utf-8, also on the pages I declare utf-8
This works very well with swedish letters etc.

Hoever If I try to echo the output from the database using htmlspecialchars etc. the letters etc converts to things like this:å
What can I do about it?

 

helenp




msg:4640474
 10:24 am on Jan 27, 2014 (gmt 0)

No idea why,
but checked in phpmyadmin, and the swedish characters in that table were written that way. Other swedish letters in other tables are written well , , .
I edited the table and changed the characters so it works now.

Wonder if there can be more tables with characters like that. Is there a way to search the tables for these characters?
Something like select * From all tables (or table) where all columns Like å

lucy24




msg:4640538
 4:50 pm on Jan 27, 2014 (gmt 0)

If I try to echo the output from the database using htmlspecialchars etc. the letters etc converts to things like this:å
What can I do about it?

Why do you want to do anything about it? Isn't that exactly what "htmlspecialchars" means? Replace each character with its named HTML entity. (Why someone would want to do this, since it makes your code unreadable, is a whole nother issue.)

There is probably an Official Source somewhere. But I've always used the trio of lists here [htmlhelp.com]. The ones used in Swedish-- and all other Western European languages-- are under "Latin-1 Entities".

Entities-- whether named or numerical-- are rarely needed today. But there was a time when browsers could only display characters that had named HTML 4 entities.

The pattern is &\w+; (ampersand, string of word characters, semicolon). Note that this includes essential entities such as —   > and so on, so you need to make some exclusions before doing any global replace.

helenp




msg:4640546
 6:22 pm on Jan 27, 2014 (gmt 0)

Lucy,
It was an error, I had the html entities in the database,
and when I tried to validate the output, they were showned just as they were in the database, instead of converting them to utf-8 as you can see in my second post.

lucy24




msg:4640576
 9:42 pm on Jan 27, 2014 (gmt 0)

as you can see in my second post.

I hope not exactly as I see, because I'm getting Cyrillic letters :)

helenp




msg:4640580
 9:53 pm on Jan 27, 2014 (gmt 0)



I hope not exactly as I see, because I'm getting Cyrillic letters :)

:)

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