VB verse Java
Well, I supose that's an attention getter at least. But I have a related problem. I wrote a program a while back in Visual BASIC which did a simple unicode encryption. It took a password and added the value of letters within your password to the value of letters within your message to be encrypted. It then saved it as a sequential text file.
Now, when I went to decrypt these using the same algorythm(except backwards to decrypt) in Java I have serious logic errors. I get unicode values of 65,000 and something and 8,000 and something. Values that should never happen when two ASCII values are added together.
My best guess is that there is repetition in unicode, and some of the low end letters like e, m, and h are also up there in high numbers. And that Visual BASIC starts at the bottom and looks for your character equivalent, and Java looks at the top. This is just my guess. VB decrypts it correctly, not to mention faster.....
Basically, I need an algorythm to convert unicode values to integer values and then back to unicode. And it needs to work beyond 128! I know how to do it for A-z but I need to do it after z!
Thanks
I did that, and I get negative numbers and positive numbers. Obviously negative numbers aren't what I want.
I think I may just write a VB program to decrypt it all to regular characters(32-128) and then use Java to enxrypt it again. I think then Java will be able to deal with it. Obviously VB must use ASCII, or some odd unicode character set. Unless it's something wierd in Java. I need to expirament.
32-128 are integers, small letters, and capital letters, and punctuation in ASCII and also Unicode.
65 = A
66 = B
See where I'm coming from now? And numbers stored in a text file are quite similar to letters, they use the same method to store the two in text files.
Um by get, I mean that's what I read from the file. If I print out the contents of the array of integers that I read it into I get negative numbers.
Unicode has 2^32 characters, integers are numbers from -2^31 to 2^31.
When you are converting a Unicode character to an integer, obviously you get negative numbers, too.
If you want to read a text file encoded in ASCII. Try the following:
1) read it as byte array
2)use
String(byte[] bytes, String charsetName)
where charsetName = "US-ASCII"
If you want to write a Unicode text as ASCII, use:
[code]PrintStream(OutputStream out, boolean autoFlush, String encoding)/code]
where encoding = "US-ASCII"