escapeString static method
Escape an ldap string used in a search filter. The LDAP spec requires *,),(,\ and null to be escaped.
Implementation
static String escapeString(String s) {
var buf = StringBuffer();
for (var c in s.codeUnits) {
switch (c) {
case 0x2a: // *
case 0x28: // )
case 0x29: // )
case 0x00: // null
case 0x5c: // \
buf.write('\\');
buf.write(c.toRadixString(16));
break;
default:
buf.writeCharCode(c);
break;
}
}
return buf.toString();
}