« first day (1468 days earlier)      last day (3475 days later) » 

7:00 PM
Ok lemme try that
 
Ima head home now...
cya around, guys ;)
 
cya
 
@Nezam that's what I'm looking for
Everything should be in UTF8.
 
fge
Java 7's java.nio.file is definitely exciting
 
@Nezam using this: options.put(fields[0].toString().toLowerCase(Locale.ENGLISH),String.valueOf( fields[2].toString().trim().toLowerCase(Locale.ENGLISH)));
Is not good
 
fge
7:02 PM
Access your Google Drive account using a FileSystem; how cool is that
 
You shouldn't use Locale.English for strings
you should be keeping them in UTF8
 
fge
@Kylar encodings and locale are completely unrelated
 
@fge I understand but he could be breaking something - by converting the strings he's putting into the map into a Locale.English, he may be using a raw string (or unlocale'd string) to try and fetch it.
Because the way that something is upper/lowercased changes with the Locale
and he may have something that looks the same but has different underlying characters
It's unlikely, admittedly
 
10-31 00:35:00.399: I/System.out(25597): Key:��d��r��i��v��e��s��t��o��r��e��d��i��r��e��c��t��
10-31 00:35:57.256: I/System.out(25597): Key:��u��s��e�� ��m��u��l��t��i��m��o��n��
10-31 00:35:57.256: I/System.out(25597): Key:��a��u��d��i��o��c��a��p��t��u��r��e��m��o��d��e��
10-31 00:35:57.256: I/System.out(25597): Key:��g��a��t��e��w��a��y��c��r��e��d��e��n��t��i��a��l��s��s��o��u��r��c��e��
10-31 00:35:57.256: I/System.out(25597): Key:��a��u��d��i��o��m��o��d��e��
10-31 00:35:57.256: I/System.out(25597): Key:��v��i��d��e��o��p��l��a��y��b��a��c��k��m��o��d��e��
BOOM!
 
7:07 PM
And there we go.
 
So what do i do to it? Shall i remove that LOCALE thingy?
 
I don't know offhand. I'd need to see the actual utf8 underlying characters before and after
Do you have the file that you're reading?
can you put it on dropbox or google drive and let me se it?
see it?
 
@Kylar sure
 
I copied your pastie and I'll do a quick debug on the incoming stuff
 
7:13 PM
Got it
give me a few minutes.
 
@Kylar Go go Kylar!
 
OK your input file is totally corrupt, that's where your problem is
You've got null bytes injected in-between each character
that's why you're seeing that shit.
Give me a sec to clean it up
cat /tmp/Default.rdp | perl -np -e 's/\0//g' > /tmp/NewDefault.rdp
That will clean all the nulls out of your input file
 
this is the prob.. the client sent me this file as a demo..
i dont know what other shit he might use to breakdown my code..
how should i handle it in my code?.. lemme try to go over that locale thing
 
So your code is fine
No that's not the problem
You're behaving correctly, he just sent you garbage
2
 
@Nezam @Kylar There is nothing wrong with that file. It is a normal text file in the UTF-16LE character encoding. The null bytes are part of the encoding.
 
7:23 PM
No matter how hard you try, you can't make a good meal with trash.
 
@Boann did you see my pastie and how i am putting the values into HashMap
 
Ugh, that's shitty
You can specify that when you read it and convert it
but you need to know that's how it's encoded before you start
 
now whats the solution to this thing
 
@Nezam Try changing new BufferedReader(new FileReader(filename)); to new BufferedReader(new InputStreamReader(new FileInputStream(filename), java.nio.charset.StandardCharsets.UTF_16LE)). Might need to skip the byte order mark at the start of the file; not sure.
 
InputStreamReader isr = new InputStreamReader(new FileInputStream(filename), Charset.forName("UTF-16LE")) ;
        BufferedReader br = new BufferedReader(isr);
Whoops, Boann beat me to it
but that'll mess up if he sends it in any other format
 
7:29 PM
@Kylar thats okay i will tell him that if this works well
 
Surprising that Java doesn't have a standard method to auto-detect character encoding.
 
It's cause there's no equivalent of a magic number
:/
and because stuff like Ascii is technically valid UTF8
so... which would you mark it as
:/
 
The byte order mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream. It is encoded at U+FEFF byte order mark (BOM). BOM use is optional, and, if used, should appear at the start of the text stream. Beyond its specific use as a byte-order indicator, the BOM character may also indicate which of the several Unicode representations the text is encoded in. Because Unicode can be encoded as 16-bit or 32-bit integers, a computer receiving these encodings from arbitrary sources needs to know which byte order the integers are encoded in. The BOM gives the...
 
BOM use is optional,
Sadly
 
It's optional but that file does apparently have one.
 
7:30 PM
@Vogel612 I have done it using servlet httpurlconnection. It worked fine without adding any headers. Previously I was requesting through ajax in jsp file.
 
a BIG THANKS to all of you who helped
THANK YOU!
This solved it!!
Alhumdulillaah..
 
Kylar is da BAUS
 
Well Boann beat him to the solution
 
Well, Boann is a BAUS too then
Sorry, I wasn't keeping up with what he posted, I was busy being tired
 
7:58 PM
For @Nezam and anyone else, this function will create a text Reader from an InputStream, detecting the byte order marks for UTF-8 and UTF-16, or falling back to UTF-8 is there is none: pastie.org/9686303
 
@Boann thanks.. How do i integrate it into my code ?
 
new BufferedReader(unicodeReader(new FileInputStream(filename)));
 
@Boann java.nio.charset.StandardCharsets.UTF_8 this is not supported in all api versions of android
can you provide a workaround for using this? thanks
 
@Nezam Using charset names in strings should work I guess: pastie.org/9686338
 
8:15 PM
@Boann thanks again..works flawlessly
 
@Nezam :)
 
fge
9:12 PM
My lord, what a shot!
 
9:42 PM
Hello
 
Good evening, Java!
 
Hi @Michael
 
Hey @Joe.
 
What's the good word?
 
Umm, tomato?
 
9:48 PM
I don't say it like that...
:P
 
Too bad.
You're gonna have to live with it.
 
Hey @Michael! How're things going?
 
@Kylar Hey man, good you?
 
No complaints!
 
Really? None? That's a first. ;)
 
10:04 PM
I'm drunk, so I'm happy.
 
I'm sober, yet pretty much happy....
 
10:50 PM
I just found William Shatner doing a few songs that are REALLY interesting...
 
Ben Folds?
 

« first day (1468 days earlier)      last day (3475 days later) »