From: Tal Peer Date: Thu, 17 Oct 2002 18:04:43 +0000 (+0000) Subject: New functions: X-Git-Tag: php-4.3.0pre2~312 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b941224d5deb5903fdb169dfc183720b2260d1d4;p=php New functions: fribidi_get_charsets() fribidi_charset_info() @- Added function fribidi_get_charsets() (Tal) @- Added function fribidi_charset_info() (Tal) --- diff --git a/ext/fribidi/fribidi.c b/ext/fribidi/fribidi.c index 23a999e834..aacd77cde7 100755 --- a/ext/fribidi/fribidi.c +++ b/ext/fribidi/fribidi.c @@ -43,7 +43,9 @@ #endif function_entry fribidi_functions[] = { - PHP_FE(fribidi_log2vis, NULL) + PHP_FE(fribidi_log2vis, NULL) + PHP_FE(fribidi_charset_info, NULL) + PHP_FE(fribidi_get_charsets, NULL) {NULL, NULL, NULL} }; @@ -247,6 +249,68 @@ PHP_FUNCTION(fribidi_log2vis) } /* }}} */ +/* {{{ proto array fribidi_charset_info(int charset) + Returns an array containing information about the specified charset */ +PHP_FUNCTION(fribidi_charset_info) +{ + long charset; + char *name, *title, *desc; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &charset) == FAILURE) { + return; + } + + array_init(return_value); + + switch (charset) { + case FRIBIDI_CHARSET_UTF8: + case FRIBIDI_CHARSET_ISO8859_6: + case FRIBIDI_CHARSET_ISO8859_8: + case FRIBIDI_CHARSET_CP1255: + case FRIBIDI_CHARSET_CP1256: + case FRIBIDI_CHARSET_ISIRI_3342: + case FRIBIDI_CHARSET_CAP_RTL: + name = fribidi_char_set_name(charset); + title = fribidi_char_set_title(charset); + desc = fribidi_char_set_desc(charset); + + if (name == NULL) { + name = ""; + } + if (title == NULL) { + title = ""; + } + if (desc == NULL) { + desc = ""; + } + + add_assoc_string(return_value, "name", name , 1); + add_assoc_string(return_value, "title", title, 1); + add_assoc_string(return_value, "desc", desc, 1); + break; + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown charset"); + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto array fribidi_get_charsets() + Returns an array containing available charsets */ +PHP_FUNCTION(fribidi_get_charsets) +{ + array_init(return_value); + + add_index_string(return_value, 0, "FRIBIDI_CHARSET_UTF8", 1); + add_index_string(return_value, 1, "FRIBIDI_CHARSET_8859_6", 1); + add_index_string(return_value, 2, "FRIBIDI_CHARSET_8859_8", 1); + add_index_string(return_value, 3, "FRIBIDI_CHARSET_CP1255", 1); + add_index_string(return_value, 4, "FRIBIDI_CHARSET_CP1256", 1); + add_index_string(return_value, 5, "FRIBIDI_CHARSET_ISIRI_3342", 1); + add_index_string(return_value, 6, "FRIBIDI_CHARSET_CAP_RTL", 1); +} +/* }}} */ + #endif /* HAVE_FRIBIDI */ /* diff --git a/ext/fribidi/php_fribidi.h b/ext/fribidi/php_fribidi.h index 7e602bbf46..1cc33fc7f4 100644 --- a/ext/fribidi/php_fribidi.h +++ b/ext/fribidi/php_fribidi.h @@ -39,6 +39,8 @@ PHP_RSHUTDOWN_FUNCTION(fribidi); PHP_MINFO_FUNCTION(fribidi); PHP_FUNCTION(fribidi_log2vis); +PHP_FUNCTION(fribidi_charset_info); +PHP_FUNCTION(fribidi_get_charsets); #ifdef ZTS #define FRIBIDIG(v) TSRMG(fribidi_globals_id, php_fribidi_globals *, v)