Re: Unicode progress [Was: unicode.semantics adinfinitum]
| From: | Steph Fox | Date: | Sun, 25 May 2008 19:12:41 +0000 |
| Subject: | Re: Unicode progress [Was: unicode.semantics adinfinitum] | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-37869@lists.php.net to get a copy of this message | ||
Hi again Johannes,
Last one on this subject I promise...
If the script encoding doesn't match up with whatever's set in INI, I don't get as far as that stuff anyway: Warning: Illegal or truncated character in input: offset 0, state=0 in C:\sandbox\php-src\Debug_TS\help.php on line 5You were right to point out that runtime encoding isn't reliable. (Now I finally got the thing working in scripts here - there's something invisible going on with UTF-8 somewhere down the line that had me confused for a while.) A call to zend_unicode_to_string_ex() that explicitly passes the fallback converter should be good enough:
} else if (c == 'S' && Z_TYPE_PP(arg) != IS_NULL /* NULL is ok */) {
UErrorCode status = U_ZERO_ERROR;
zend_unicode_to_string_ex(UG(fallback_encoding_conv), p, pl, Z_USTRVAL_PP(arg), Z_USTRLEN_PP(arg), &status);
if (U_FAILURE(status)) {
efree(p);
return "strictly a binary string";
}
break;
}
It doesn't make sense to set unicode.fallback_encoding at script level because - as I wrote earlier - the parser may respond differently depending on its value. If your INI fallback setting clashes with your script encoding you *can't* override it locally. That being the case, I don't see how a conversion that uses the fallback encoding can be wrong here.
- Steph