How do I represent the zero-width space character (hex UTF-16 200b) in a PHP string constant in my source file? i.e. I want to add this character to a string in a test case like
$str = 'test' . $zwcHere . 'test2';
In C I could just use something like
char c = '\x200b';
Info on ZWC: http://www.fileformat.info/info/unicode/char/200b/index.htm
PHP's "characters" are 8-bit. If you want to output a character with a code higher than 128, you'll need to specify an encoding that supports that character, then output the codes that that encoding requires.
If you set UTF-8 encoding, for example, you'd print "\xE2\x80\x8B"
.
Of course, if this is HTML, you can typically use the HTML entity ref ​
as well, which wouldn't require changing the page's encoding.