I can't change charset of PHP files

Discussion in 'PHP' started by tolgafiratoglu, Aug 17, 2009.

  1. #1
    Hi there.

    I don't know why, I downloaded tried many IDE's. I convert ASCII -> UTF8, but as I close files and re-open they're still ASCII.
    The files were previously in another WAMP folder, I copied the folder to change structure and this happened. I couldn't understand
    how, why.

    Thanks by now, it'll be life saving, I lost many precious hours.

    Tolga
     
    tolgafiratoglu, Aug 17, 2009 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    Vooler, Aug 18, 2009 IP
  3. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    eclipse ide seems to be able to do it - but as Vooler said, Notepad2 (or even Notepad++ or EditPlus) should work fine.
     
    szalinski, Aug 19, 2009 IP
  4. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #4
    Notepad2 is actually too small and single executable, no installer and nobulky space consuming applciation. Small lightweight and full of features.
     
    Vooler, Aug 19, 2009 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    I'm surprised none of you suggesting Notepad2 caught this. I actually learned it from my experience with that editor. :)

    The reason you're saving as UTF-8 and it appears to be back to ASCII when you reopen the file is, well, because technically your file is in the ASCII encoding unless it's using extended characters such as accented characters that the UTF-8 character set includes on top of the ASCII characters.

    If you want editors to consider a file without any extended characters in it UTF-8, you need to include a UTF-8 BOM in the file. Be careful with that though, as that link notes a BOM can add a world of problems.

    Your best bet is to stick with ASCII unless you find that you need the extended characters later. A BOM is more trouble than it's worth.
     
    joebert, Aug 19, 2009 IP
  6. kalinchuk

    kalinchuk Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    TextMate is an awesome text editor for any programming language and it supports UTF-8 characters too. But I think it only works on a mac.
     
    kalinchuk, Aug 23, 2009 IP
  7. tolgafiratoglu

    tolgafiratoglu Well-Known Member

    Messages:
    249
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #7
    Only Notepad2 helped me, other editors couldn't solve this issue without a BOM, which is bad for many systems.
     
    tolgafiratoglu, Sep 10, 2009 IP