php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31609 str_word_count corrupts string with extended charset
Submitted: 2005-01-19 12:35 UTC Modified: 2005-01-22 14:13 UTC
From: jfo123 at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.4 OS: RH 9.0
Private report: No CVE-ID: None
 [2005-01-19 12:35 UTC] jfo123 at hotmail dot com
Description:
------------
str_word_count corrupts string with extended charset as in the swedish character set. Special chars are deleted from the string.

Reproduce code:
---------------
$title0 = "V?rlden ?r ?ngestfylld f?r katastrof";
$num_words  = str_word_count($title0, 2);
						
foreach ($num_words AS $pos => $word) {
	if ($pos < 50)
		$title .= " $word";
	}
	print $title;
}

Expected result:
----------------
V?rlden ?r ?ngestfylld f?r katastrof

Actual result:
--------------
Vrlden r ngestfylld fr katastrof

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-19 12:42 UTC] derick@php.net
Your code doesn't even parse, please provide a working script Put it in a zip/tgz file on a website if possible, and provide a link.
 [2005-01-22 07:53 UTC] jfo123 at hotmail dot com
Take away the last } nothing else.
Parsable code:
#--------------------
$title0 = "V?rlden ?r ?ngestfylld f?r katastrof";
$num_words  = str_word_count($title0, 2);
						
foreach ($num_words AS $pos => $word) {
	if ($pos < 50)
		$title .= " $word";
}
print $title;
 [2005-01-22 14:13 UTC] sniper@php.net
1) your PHP version is too old.
2) works fine with latest CVS.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 03 07:01:33 2024 UTC