Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: charset problem

  1. #1
    Regular Coder
    Join Date
    May 2006
    Posts
    107
    Thanks
    1
    Thanked 0 Times in 0 Posts

    charset problem

    Hi
    I am having charset problem at the moment, if i try:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    some of the character which are in Tarkish language don't work
    and if i use
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    others don't work.

    I even tried:
    PHP Code:
    utf8_decode()
    utf8_encode() 
    any help

  • #2
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    The source files from which the copy came from also have to be utf-8 for the chars to display properly. Try changing the charset to the same as the source.

    You need to convert the copy to utf-8 at some stage though.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #3
    Regular Coder
    Join Date
    May 2006
    Posts
    107
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?PHP
    	echo utf8_encode ("Peşin alışverişlerinize <font color=\"ff0000\">%10 indirim</font> uygulanmaktadır.");
    ?>
    
    
    </body>
    </html>
    output:
    Pesin alisverislerinize %10 indirim uygulanmaktadir.


    Can i get something as its input in utf-8?

  • #4
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,372
    Thanks
    32
    Thanked 286 Times in 280 Posts
    Specifying that the document is of the UTF-8 character set alone is not sufficient. You also need to save the document as a UTF-8-encoded document. Since you're using PHP, this means that you also need to save it as a UTF-8 document without an invisible byte order mark (BOM); PHP fails if a BOM character is present.

    An example of a program that saves as UTF-8 with the BOM is Microsoft Notepad, and an example of a program that does not is Adobe GoLive. I'm not sure of other editors that can save without a BOM; best to probably attempt a Web search for them.

    Once you've encoded the document correctly, you should be able to type any character from any character set directly into the document.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #5
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    ...I agree with meth and Arbitrator.

    I don't think that you can get it to work with utf_encode(). This function assumes that the argument is ISO-8859-1 encoded. And since 'ş' is not represented in this character set, the function would never convert a character to the utf-8 encoded version of the 'ş'-character.

    If this was the only reason why you invoked php, then you should instead insert the text directly within the HTML without using php.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •