[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Character encoding problems

Posted on 2009-04-15
5
Medium Priority
?
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 62

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 62

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 62

Accepted Solution

by:
gheist earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

650 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