Now I understand why it returns a string of zero length. Sorry to ask this question. I should have researched more before publishing. In any case, the answer is:
In the PHP manual page for htmlspecialchars :
If the input string contains an invalid sequence of code blocks in this encoding, an empty string will be returned if the ENT_IGNORE or ENT_SUBSTITUTE flags are not set.
, "" ? Wiki UTF-8 UTF-8. , " ASCII", 0-127 (MSB 0).
MSB 1 ( 128 255), , UTF-8, . 1, 0.
, , 127, 1 0. UTF-8.
, , , ENT_SUBSTITUTE ( , ENT_IGNORE, , - ).