When I pull a string from a UTF-8 encoded field in my SQL, I get a string like the following:
"& #2342;& #2369;& #2312;"
(I have inserted a space between "&" and "#" to stop this from displaying as international text, in my actual string there is no space).
This is a string of escaped characters, length of the string is 21 but it is actually representing something (international text) that is 3 characters.
Now I would like to save these 3 characters to a file. This file should be 6 (3 x 2) bytes long. But, of course, when I use fwrite with the above string I get a file of 21 bytes.
I could parse the string to get the six hex values (23,42,23,69,23 ,12) that I would need to write, but I can't even get PHP to output true binary. The following:
Outputs the number 32 in ASCII, not one byte of value 0x20. This is despite the "b" open mode! Can anyone help me with this? Ultimate goal is to save the above characters as described. Thanks!
"& #2342;& #2369;& #2312;"
(I have inserted a space between "&" and "#" to stop this from displaying as international text, in my actual string there is no space).
This is a string of escaped characters, length of the string is 21 but it is actually representing something (international text) that is 3 characters.
Now I would like to save these 3 characters to a file. This file should be 6 (3 x 2) bytes long. But, of course, when I use fwrite with the above string I get a file of 21 bytes.
I could parse the string to get the six hex values (23,42,23,69,23 ,12) that I would need to write, but I can't even get PHP to output true binary. The following:
Code:
$fh = fopen("text.txt", "wb");
fwrite($fh, (int)32);
Comment