Implement user conversion error handler support. Works as normal error

handler, in that it can return false to make the default one take over.
Handler signature is:
  user_handler($direction, $encoding, $char_byte, $offset, $message)

Also removed support for using exceptions in default error handler.
This commit is contained in:
Andrei Zmievski 2006-06-21 20:17:21 +00:00
parent 9573e77249
commit e875205714
6 changed files with 115 additions and 37 deletions

View file

@ -62,7 +62,7 @@ static PHP_FUNCTION(unicode_decode)
status = U_ZERO_ERROR;
num_conv = zend_convert_to_unicode(conv, &dest, &dest_len, str, str_len, &status);
if (U_FAILURE(status)) {
zend_raise_conversion_error_ex("could not decode binary string", conv, ZEND_TO_UNICODE, num_conv, (flags & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC);
zend_raise_conversion_error_ex("could not decode binary string", conv, ZEND_TO_UNICODE, num_conv TSRMLS_CC);
efree(dest);
ucnv_close(conv);
RETURN_FALSE;
@ -114,7 +114,7 @@ static PHP_FUNCTION(unicode_encode)
num_conv = zend_convert_from_unicode(conv, &dest, &dest_len, uni, uni_len, &status);
if (U_FAILURE(status)) {
int32_t offset = u_countChar32(uni, num_conv);
zend_raise_conversion_error_ex("could not encode Unicode string", conv, ZEND_FROM_UNICODE, offset, (flags & ZEND_CONV_ERROR_EXCEPTION) TSRMLS_CC);
zend_raise_conversion_error_ex("could not encode Unicode string", conv, ZEND_FROM_UNICODE, offset TSRMLS_CC);
efree(dest);
ucnv_close(conv);
RETURN_FALSE;