php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49564 mb_detect_encoding() manual page doesn't mention FALSE return value
Submitted: 2009-09-15 15:13 UTC Modified: 2009-11-13 22:14 UTC
From: aharvey@php.net Assigned: rquadling (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: aharvey@php.net
New email:
PHP Version: OS:

 

 [2009-09-15 15:13 UTC] aharvey@php.net
Description:
------------
The documentation for mb_detect_encoding() fails to note that FALSE is a possible return value from the function if no encoding can be detected. This can be demonstrated trivially with the reproduce code below, and is obviously intended behaviour, looking at ext/mbstring/mbstring.c and ext/mbstring/libmbfl/mbfl/mbfilter.c.

My suggestion would be to replace the Return Values text with the following:

"Returns the detected character encoding, or FALSE if the encoding cannot be detected from the given string."

Reproduce code:
---------------
<?php
// On the off chance you want to see this in action, any high-bit
// character in the input should return false in strict mode when
// ASCII is the only possible encoding.
var_dump(mb_detect_encoding("f??", "ASCII", true));

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-15 16:22 UTC] svn@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=288349
Log: Fix#49564 - Returns false if encoding cannot be determined.
 [2009-11-13 22:14 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 14:00:01 2026 UTC