Results 1 to 5 of 5
  1. #1
    cooper01 is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default Java and PHP4 ASCII

    Hi All

    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?

    Thanks

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

    Default

    Quote Originally Posted by cooper01 View Post
    Hi All

    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?

    Thanks
    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.

    -Gary-

  3. #3
    cooper01 is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default

    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
    Java Code:
    $keychar = 
    $iASCII = ord($keychar)
    PHP returns 140

    The way I would convert the character in Java would be
    Java Code:
    Char cCharacter = 
    Int iASCII = cCharacter
    Java returns 338


    Would anyone be able to tell me, how I can return the same ASCII value within Java?

    Thanks

  4. #4
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    952
    Rep Power
    5

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    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.

    kind regards,

    Jos

Similar Threads

  1. Binary and ASCII
    By mac in forum New To Java
    Replies: 4
    Last Post: 01-10-2010, 07:31 PM
  2. Reading ASCII / Unicode character in Java
    By NGRaju in forum New To Java
    Replies: 2
    Last Post: 09-16-2008, 11:02 PM

Posting Permissions

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