Skip to main content
Active reading. Removed meta information (this belongs in comments). A reference changed.
Source Link
Peter Mortensen
  • 31.2k
  • 22
  • 111
  • 134

I put this in here for completeness:

Assuming PHP is compiled with PCRE, it most often is also enabled with UTF-8. So as explicitly asked for in the question, this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argumentargue that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However, in my practical developer livelife, this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing pcrePCRE as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.

I put this in here for completeness:

Assuming PHP is compiled with PCRE it most often is also enabled with UTF-8. So as explicitly asked for in the question this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argument that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However in my practical developer live this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing pcre as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.

Assuming PHP is compiled with PCRE, it most often is also enabled with UTF-8. So as explicitly asked for in the question, this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argue that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However, in my practical developer life, this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing PCRE as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

I put this in here for completeness:

Assuming PHP is compiled with PCRE it most often is also enabled with UTF-8. So as explicitly asked for in the question this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argument that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However in my practical developer live this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing pcre as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.

I put this in here for completeness:

Assuming PHP is compiled with PCRE it most often is also enabled with UTF-8. So as explicitly asked for in the question this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argument that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However in my practical developer live this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing pcre as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.

I put this in here for completeness:

Assuming PHP is compiled with PCRE it most often is also enabled with UTF-8. So as explicitly asked for in the question this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argument that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However in my practical developer live this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing pcre as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.

Source Link
hakre
  • 200k
  • 55
  • 455
  • 870

I put this in here for completeness:

Assuming PHP is compiled with PCRE it most often is also enabled with UTF-8. So as explicitly asked for in the question this very simple regular expression can detect invalid UTF-8 strings, because those won't match:

preg_match('//u', $string); 

You can then argument that the u modifier (PCRE_UTF8) is not always available, and true, this can happen as the this question shows:

However in my practical developer live this never was an issue. It is more an issue that the PCRE extension is not available at all, which would render any answer containing pcre as useless (even mine here). But most often that issue was more an issue of the past as of today minus some years.

A more lengthy answer similar to this one has been given in the somehow duplicate question:

So I think this question should highlight more of the benefits the suggested answer ships with.