Solved

Character encoding problems

Posted on 2009-04-15
5
328 Views
Last Modified: 2013-11-19
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
Comment
Question by:R7AF
  • 3
  • 2
5 Comments
 
LVL 61

Expert Comment

by:gheist
ID: 24150509
What do you mean by pages - 4kB CPU pages/16kB database pages/Webpages
0
 
LVL 13

Author Comment

by:R7AF
ID: 24150765
I mean webpages.
0
 
LVL 61

Expert Comment

by:gheist
ID: 24150887
here is possibility for dual interpretation - from page headers and from Meta tags....
0
 
LVL 13

Author Comment

by:R7AF
ID: 24155203
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
 
LVL 61

Accepted Solution

by:
gheist earned 500 total points
ID: 24155895
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to count occurrences of each item in an array.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now