java - Writing ASCII values directly -


i working on android app in java writes data receive via bluetooth arrayadapter displayed on screen. of data includes new lines , carriage returns , instead of executing respective operations in arrayadapter, instead want display literal ascii value (\n, \r) in arrayadapter. there natural way within android sdk or need parse data in order this? here bit of code use set arrayadapter:

byte[] writebuf = (byte[]) msg.obj; string writemessage = new string(writebuf); conversationarrayadapter.add("me:  " + writemessage); 

thanks input!

you have escape them inside string display "\n" , "\r", otherwise view iterpret character itself; like:

string writemessage = new string(writebuf); string escaped = writemessage.replaceall("\n","\\n").replaceall("\r","\\r"); 

not 100% sure of syntax, that's idea.


Comments