Skip to content

Conversation

masakielastic
Copy link
Contributor

@masakielastic masakielastic commented Sep 15, 2016

Both str_check_encoding and str_scrub have same feature as mb_check_encoding and mb_scrub:

bool str_check_encoding ([ string $str[,string $encoding = ini_get("default_charset") ]] )
string str_scrub ([ string $str[,string $encoding = ini_get("default_charset") ]] )

fallback functions can be implemented by htmlspecialchars and htmlspecialchars_decode since PHP 5.4.0.

var_dump(
  // str_check_encoding
  "" === htmlspecialchars_decode(htmlspecialchars("a\x80b")),
  // str_scrub
  "a\u{fffd}b" === htmlspecialchars_decode(htmlspecialchars("a\x80b", ENT_SUBSTITUTE))
);

@@ -98,7 +98,7 @@ static char *get_default_charset(void) {

/* {{{ get_next_char
*/
static inline unsigned int get_next_char(
PHPAPI unsigned int get_next_char(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good symbol name to export.

@@ -373,7 +373,7 @@ static inline unsigned int get_next_char(
/* {{{ entity_charset determine_charset
* returns the charset identifier based on current locale or a hint.
* defaults to UTF-8 */
static enum entity_charset determine_charset(char *charset_hint)
PHPAPI enum entity_charset determine_charset(char *charset_hint)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not a good name for export.

PHPAPI zend_string *php_escape_html_entities(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset);
PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode);
PHPAPI zend_string *php_unescape_html_entities(unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset);
PHPAPI unsigned int php_next_utf8_char(const unsigned char *str, size_t str_len, size_t *cursor, int *status);
PHPAPI unsigned int get_next_char(enum entity_charset charset, const unsigned char *str, size_t str_len, size_t *cursor, int *status);
PHPAPI enum entity_charset determine_charset(char *charset_hint);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take your lead on naming from the prototypes above these.

/* {{{ proto bool str_check_encoding([string str[, string encoding]]) */
PHP_FUNCTION(str_check_encoding)
{
zend_string *str, *enc = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange indentation.

@nikic
Copy link
Member

nikic commented Oct 17, 2016

I'm -1 on this. Porting functions from ext/mbstring to ext/standard because some people don't have mbstring installed makes no sense to me. We can't just duplicate our entire extension functionality into ext/standard because that's always available.

@krakjoe
Copy link
Member

krakjoe commented Jan 3, 2017

Since we cannot merge this patch in it's current form because it's not satisfactory quality, and it has merge conflicts, and the author seems to have abandoned working on it, I'm closing this PR.

@krakjoe krakjoe closed this Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants