Java and PHP4 ASCII
Currently I am developing a utility in Java, which needs to read a file, which is used in a PHP 4 application. This file is encrypted using a simple ASCII math and key encryption.
The Java application needs to read the file and return the same answer as the original PHP application, but on some characters it returns a different value. The PHP Application uses ord function, to convert a character into ASCII
Does anyone know how I could get the Java code, to return the same ASCII code?
There is a bit too much riddle in this question. Please show us your code, show us some Strings that work correctly, and show us some Strings that don't work.
Originally Posted by cooper01
Sorry about that.
An example of the character that returns a different ASCII value is Œ
The way I would convert the character in PHP would be
PHP returns 140
$keychar = “Œ”
$iASCII = ord($keychar)
The way I would convert the character in Java would be
Java returns 338
Char cCharacter = “Œ”
Int iASCII = cCharacter
Would anyone be able to tell me, how I can return the same ASCII value within Java?
A nice read; here's another nice read; it's an old email conversation by Rob Pike (yep, that one) about the origins of utf-8.
Originally Posted by gcalvin