Adb shell input text does not accept & ampersand character
When I enter text with a symbol, then my full text is entered into the edit box.
D: \ Apps \ Android-SDK \ tools> adb shell input text hello & hello "hello" is not recognized as an internal or external command, runtime program, or batch file.
It was only entered by hello. but no other and and hello characters are entered.
When I type below adb device and adb device It will give 2 outputs.
The adb shell input text value must be accepted in a different format like in quotes or something.
How can I enter this value and symbol?
source to share
( ) < > | ; & * \ ~ " '
and all the space needs to be shielded. The space can be replaced with %s
.
I wrote an android command line tool for this call inputer
.
Function from my code here (uses regex
):
//e.g. convert string "hello world\n" to string "hello%sworld\n"
char * convert(char * trans_string)
{
char *s0 = replace(trans_string, '\\', "\\\\");
free(trans_string);
char *s = replace(s0, '%', "\\\%");
free(s0);
char *s1 = replace(s, ' ', "%s");//special case for SPACE
free(s);
char *s2 = replace(s1, '\"', "\\\"");
free(s1);
char *s3 = replace(s2, '\'', "\\\'");
free(s2);
char *s4 = replace(s3, '\(', "\\\(");
free(s3);
char *s5 = replace(s4, '\)', "\\\)");
free(s4);
char *s6 = replace(s5, '\&', "\\\&");
free(s5);
char *s7 = replace(s6, '\<', "\\\<");
free(s6);
char *s8 = replace(s7, '\>', "\\\>");
free(s7);
char *s9 = replace(s8, '\;', "\\\;");
free(s8);
char *s10 = replace(s9, '\*', "\\\*");
free(s9);
char *s11 = replace(s10, '\|', "\\\|");
free(s10);
char *s12 = replace(s11, '\~', "\\\~");
//this if un-escaped gives current directory !
free(s11);
char *s13 = replace(s12, '\¬', "\\\¬");
free(s12);
char *s14 = replace(s13, '\`', "\\\`");
free(s13);
// char *s15 = replace(s14, '\¦', "\\\¦");
// free(s14);
return s14;
}
source to share