View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 10:32 AM
firewoodtim@yahoo.com
 
Posts: n/a
Default Re: mixed encodings - how to manage

On Sun, 20 Jan 2008 20:23:01 +0100, "J.O. Aho" <user@example.net>
wrote:

>firewoodtim@yahoo.com wrote:
>
>> This is what I thought was likely, and it certainly makes sense.
>> However, what threw me was concern about out how a browser set to read
>> an html file using utf8 would be able to recognize a 1 byte character,

>
>1 byte characters has a ASCII value of 127 or less.
>
>> when it was also expecting 2 or 3 or even 4 byte characters as well.

>
>Those start with a 128 or higher ASCII value.


So just to be sure, let me see if I understand this correctly.

I have a PHP script running that takes latin1 data from a variety of
MySQL columns and uses them as CSS values in "style" attributes. These
do not have to be converted to utf8 encoding, because latin1 values
are a subset of utf8 and any conversion would result in the same 1
byte characters that I started with anyway.

In the case of the utf8 fields that will be displayed visibly in the
browser, not used as html styling values, these will be correctly
interpreted by the browser, since if there are any non-latin1
characters, they will be recognized by the browser as utf8 from their
encoding values (128 or higher) and displayed correctly.

This means that if I specify utf8 using the header() function and
again in the meta tags, and then use latin1 and utf8 characters in the
script to form the styling and visible content respectively,
everything should turn out OK.

Am I right?
Reply With Quote