• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

Character encoding problems

I'm working on a website that has a nasty problem. Some pages use UTF-8, other ISO-8859-1. Data is entered in the database using both methods. Now it turns out that for (at least) one of those pages the encoding is changed, resulting in data in the table that is UTF-8 for some records, and ISO-8859-1 for other. The database is set to 8859-1.

Is it possible to detect per record which encoding is used? Depending on the encoding I could use a php-function like utf8-encode.
0
R7AF
Asked:
R7AF
  • 3
  • 2
1 Solution
 
gheistCommented:
What do you mean by pages - 4kB CPU pages/16kB database pages/Webpages
0
 
R7AFAuthor Commented:
I mean webpages.
0
 
gheistCommented:
here is possibility for dual interpretation - from page headers and from Meta tags....
0
 
R7AFAuthor Commented:
The data is already entered in the database table. The data is a mix of ISO-8859-1 and UTF-8. When I publish the data on a html page (PHP generated), and set that page to either ISO-8859-1 or UTF-8 (using php page headers or html meta tags), some of those records don't have the correct encoding type. Because I don't know which records that are, I would like to be able to translate the text into another encoding when publishing that text. I would like to know whether it's possible to detect the encoding type based on a text string.
0
 
gheistCommented:
PHP iconv or mbstring can detect encodings to some extent.
You can try PostgreSQL's iconv functionality also to emit extra encoding field, or convert everything to UTF on output.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now