cant work with ASCII extended chars in PHP

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
vikingro
Forum Newbie
Posts: 2
Joined: Wed Feb 24, 2010 3:54 am

cant work with ASCII extended chars in PHP

Post by vikingro »

hi,
i am kinda new to php and i need to work with ASCII II characters those with code beyond 127.

The problem is that I am trying to run this script below, and I dont get my required characters from ASCII table that had to represent the ascii codes beyond 127.

Code: Select all

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>
    </title>
    </head>
    <body>
 
    <?php
        for ($j = 128; $j<255; $j++){
            echo (chr($j)) ."&nbsp;&nbsp;";
        }
?>      
    </body>
</html>
 
I have tried without using the meta header. I have also tried to use the utf8_encode php function, but nothing has helped.
I need to manipulate in my php page ascii characters like theese.
« - 174
? - 218
? - 251
ü - 129
? - 183
? - 169
» - 175
? - 210

If anyone has an idea about how to solve this would be very appreciated.
Thank you very much.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: cant work with ASCII extended chars in PHP

Post by AbraCadaver »

You won't get all, but try:

Code: Select all

echo htmlentities(chr($j)) ."&nbsp;&nbsp;";
// or better
echo "&#" . $j ."&nbsp;&nbsp;"; 
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: cant work with ASCII extended chars in PHP

Post by Apollo »

vikingro wrote:i am kinda new to php and i need to work with ASCII II characters those with code beyond 127.
There are no ASCII characters above 127.

Perhaps you mean ANSI, and in that case, which ANSI encoding? Win1252? Latin1? CP950 (Chinese) ?

Furthermore, in your example you output a UTF-8 content type in your HTML header. But the data you are outputting is not UTF-8 encoded.
You mentioned you tried utf8_encode, but that converts ISO-8859-1 Ansi to UTF-8, and that particular ansi encoding does not even contain characters 127-159.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: cant work with ASCII extended chars in PHP

Post by AbraCadaver »

First let me say that I know very little about character encoding, unicode, etc., but just looking here shows me the characters that are also included in the extended ASCII range: http://www.utf8-chartable.de/unicode-ut ... inhtml=hex

This works for me, though as I said, I don't have much experience with it:

Code: Select all

for ($j=hexdec('a0'); $j<=hexdec('3ff'); $j++){
    echo "&#x".dechex($j).";&nbsp;&nbsp;";
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
MichaelSK
Forum Newbie
Posts: 4
Joined: Wed Feb 24, 2010 4:15 pm
Location: Seattle

Re: cant work with ASCII extended chars in PHP

Post by MichaelSK »

See ICONV
vikingro
Forum Newbie
Posts: 2
Joined: Wed Feb 24, 2010 3:54 am

Re: cant work with ASCII extended chars in PHP

Post by vikingro »

UPDATE: I have solved. The encoding was CP437, wich btw doesnt work in php.
Anyway, I have found out that only putty was displaying in cp437 where the password was encripted with Latin1.

thanks for replies.
Perhaps you mean ANSI, and in that case, which ANSI encoding? Win1252? Latin1? CP950 (Chinese) ?
You are right. I need the ANSI encoding first used by IBM in DOS.
I have found it in Windows character map: DOS:United States.
Now the problem is if I can find it's name to use it in php header.

PS: I need to decode an Informix 4GL coded password. Anyone knows the precise name of the charset in 4GL?
Post Reply