Question

I am sending letter A (string letter = "A\n") on my android phone to a device. In matlab the code is set(s1,'Terminator', 'CR'). I would like to know how this is done from on an android phone. I want an enter after I sending letter A. Thanks for you answers in advance

Was it helpful?

Solution

I have found the answer. "\n" is new line feed, "\r" is carriage return. "\n" = 10 in decimal; and "\r" = 13 in decimal. so I want 13 in decimal for Carriage return, "\r" worked for me instead of "\n". (Look at the ASCII table closer :))

OTHER TIPS

String num = String.valueOf(number);
String cr =  String.valueOf(number_cr);
String s = num + "\n" + cr;

or you can try something like:

String eol = System.getProperty("line.separator");  
String s = num + eol + cr;

See How to insert a new line in strings in Android for more. Hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top