php code where are you? char set woes?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

php code where are you? char set woes?

Post by neophyte »

Okay folks what in the world would cause my php code (somefile.php) to show up in my browser like:
椀琀栀椀渀 嬀⸀⸀⸀崀ഀ $quoted_pair = " $esc [^$NonASCII] "; // an escaped character਍ഀ // Items 22 and 23, comment.਍    ⼀⼀ 䤀洀瀀漀猀猀椀戀氀攀 琀漀 搀漀 瀀爀漀瀀攀爀氀礀 眀椀琀栀 愀 爀攀最攀砀Ⰰ 䤀 洀愀欀攀 搀漀 戀礀 愀氀氀漀眀椀渀最 愀琀 洀漀猀琀ഀ // one level of nesting.਍    ␀挀琀攀砀琀 㴀 ∀ 嬀帀␀攀猀挀␀一漀渀䄀匀䌀䤀䤀␀䌀刀氀椀猀琀⠀⤀崀 ∀㬀ഀ ਍    ⼀⼀ ␀䌀渀攀猀琀攀搀 洀愀 
If it shows up on your screen like mine it's a bunch of oriental characters mixed with what appears to be readable php code.

I would assume it some sort of file type assocation/mime/character set issue. (Obviously I don't know anything about character sets) Anybody got any ideas how to fix it? I'm on winxp pro and I saved it out of phpDesigner 2006
Last edited by neophyte on Fri Mar 03, 2006 10:36 am, edited 1 time in total.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Totally the wrong forum.. sorry guys.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

open it in notepad and see what's in there
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Replacement topic elsewhere?

Anyways....if the original text was ASCII (basic english characters) this shouldn't be happening - probably need a code example to figure it out. Check also if the text is being wrung through any string functions. Typically however, in my limited experience, charset corruption will echo a question mark or two in place of the corrupted character. I say corrupted because PHP without mbstring is useless at non ASCII string manipulation... Onwards to PHP6 ;)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

That's the weird thing, it appears just fine in phpDesigner. But when I first opened it in FirstPage I got a single weird character and that's it. SO I went back to phpDesigner. The file was saved in a unix format. So I used php designer to save it in a windows format. (Not sure what exactly this does.) Uploaded the files and now the files spit out english characters but no php parsing. Shows the entire file on screen through my browser with out the first <?php tag. Weird. So now I'm stuck. I'm sure it's a local thing.

So I just tried opening them in notepad. File->open and in the pull down .txt files and type ANSI. None of the aforementioned files appeared in the window to open so I tried the other formats: unicode, utf 8. No files show up. I think that might be a problem. The php files only appeared for opening if i selected show all files. So I opened one and got western characters. Saved the file over writing the previous. Uploaded it. Western characters plan text no parsing.


Ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe you got a BOM in there that's messing with parsing?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

I've had a similar problem before. Open the file, Save As. Make sure you choose ANSI encoding.

If you can't choose the encoding open it in an editor where you can, eg. EditPlus.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Thank you jayshields! That did the trick. Saved the file as ANSI and I've got php working again.
Post Reply