Why won't Java's BufferedReader act like Objective-C's NSData? -


i'm developing application running on android , ios devices. app need xml stream url. xml not safe, because lines, example :

révélation

will become :

r�v�lation

of course know best thing fix xml generator script. i'm working developer firm , don't have access it, moment i'm trying can have.

now here reason of topic. when put data in objective-c's nsdata object :

nsdata *data = [[nsdata alloc] initwithcontentsofurl:[nsurl urlwithstring:url]]; 

and try read every byte :

nsuinteger len = [data length]; byte *bytedata = (byte*)malloc(len); memcpy(bytedata, [data bytes], len); for(int = 0 ; < len ; i++) {     nslog(@"%d",bytedata[i]); } 

it correctly displays int value of char, special character or not. have handle (unichar)bytedata[i] solve it.

no java , android, i'm trying basic bufferedreader operation.

url myurl = new url(url); bufferedreader in = new bufferedreader(new inputstreamreader(myurl.openstream())); 

then print every char's int 1 one :

int i; while((i = in.read()) != -1) system.out.print(i); 

but java, doing replacement char's id (65533) instead of one, , can't manage replace it.

any idea? reading me.

bufferedreader in = new bufferedreader(         new inputstreamreader(myurl.openstream(), "utf-8")); 
  • inputstreams bytes, binary data.

  • readers characters, string, text.

the inputstreamreader bridges conceptual difference, saying encoding binary data in, , has optional parameter encoding. default encoding of current platform - not portable.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -