Unicode Character 'SUBSTITUTE' (U+001A) troubles...

R

Robert Lehman

I'm implementing a version of the "Mini-AES" (http://findarticles.com/
p/articles/mi_qa3926/is_200210/ai_n9129484) in Ruby and have all of
the bit shifts and stuff working..

The problem I'm having is with the file input. When ever the input
file has the character U+001A (http://www.fileformat.info/info/unicode/
char/001a/index.htm), it stops reading in the line (and thus doesn't
complete the whole cipher text).

Basically, here is the code that I'm using to read the input:
fin = File.open(ARGV[0], 'r')
plainText = ""
while (line = fin.gets)
plainText += line
end
fin.close

Here is a sample line of cipher text:
týH†a¤j{ÀìyMšyMÇÜ«àÃSÙ¿àé4þF&käj{Àì

if I read this line in, it would only read "týH†a¤j{ÀìyMšyM" and skip
the rest.
 
R

Robert Lehman

I'm implementing a version of the "Mini-AES" (http://findarticles.com/
p/articles/mi_qa3926/is_200210/ai_n9129484) in Ruby and have all of
the bit shifts and stuff working..

The problem I'm having is with the file input.  When ever the input
file has the character U+001A (http://www.fileformat.info/info/unicode/
char/001a/index.htm), it stops reading in the line (and thus doesn't
complete the whole cipher text).

Basically, here is the code that I'm using to read the input:
fin = File.open(ARGV[0], 'r')
plainText = ""
while (line = fin.gets)
  plainText += line
end
fin.close

Here is a sample line of cipher text:
týH†a¤j{ÀìyMšyM ÇÜ«àÃSÙ¿àé4þF&käj{Àì

if I read this line in, it would only read "týH†a¤j{ÀìyMšyM" and skip
the rest.

I'm using Windows btw.
 
R

Robert Lehman

Robert said:
fin = File.open(ARGV[0], 'r')
the rest.
I'm using Windows btw.

Open the file with "rb" instead of "r".

I tried using rb and the output spits out 1/2 plain text and 1/2
random Unicode.

Our project is only allowed to be run on Linux and it seems to work
fine on there, so I'll just leave the Windows problem alone unless
someone suggests a good fix.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top