1 Replies - 1571 Views - Last Post: 15 October 2010 - 12:37 PM Rate Topic: -----

#1 Guest_JavaCoder*


Reputation:

UTF-8 Byte Stream

Posted 15 October 2010 - 12:04 PM

Hey
I need to validate if the provided byte stream is UTF-8.
I need help with start and programming logic. I could accept file which would have byteStream or i could use Scanner and they would input the byteStream. We don't know how long the byte stream is.
I need to make sure that bytestream is UTF-8 validated.

This is security problem. I would take in a stream byte. And I would have to check it if its valid UTF-8. There is some way to do that. Probably i would need to go byte by byte or bit by bit to see its valid UTF-8 format. The main logic is to not to accept anything else then UTF-8, and if it does encounter something thats not UTF-8, then say, "NOT Valid Stream"
Any help is appreciated...
Thank You

Is This A Good Question/Topic? 0

Replies To: UTF-8 Byte Stream

#2 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2975
  • View blog
  • Posts: 11,224
  • Joined: 15-July 08

Re: UTF-8 Byte Stream

Posted 15 October 2010 - 12:37 PM

You can force a Scanner to accept a specific encoding:

Scanner scan = new Scanner(file_or_string_object, "UTF-8");


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1