Skip to content

Commit

Permalink
Define string_lower() as a function that will use mb_strlower() if av…
Browse files Browse the repository at this point in the history
…ailable, and fall back to strtolower() if not.

Update install_category_migrate() to use the new function; affects #9161, 9298.
  • Loading branch information
amyreese committed Dec 9, 2008
1 parent 4826187 commit c675a01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion admin/install_functions.php
Expand Up @@ -58,7 +58,7 @@ function install_category_migrate() {
foreach( $t_data as $t_project_id => $t_categories ) {
$t_inserted = array();
foreach( $t_categories as $t_name => $t_true ) {
$t_lower_name = strtolower( $t_name );
$t_lower_name = string_lower( $t_name );
if ( !isset( $t_inserted[$t_lower_name] ) ) {
$query = "INSERT INTO $t_category_table ( name, project_id ) VALUES ( " . db_param() . ', ' . db_param() . ' )';
db_query_bound( $query, array( $t_name, $t_project_id ) );
Expand Down
16 changes: 16 additions & 0 deletions core/string_api.php
Expand Up @@ -37,6 +37,22 @@
$g_cache_html_valid_tags = '';
$g_cache_html_valid_tags_single_line = '';

/**
* Return a string with all alphabetical characters converted to lowercase,
* using an appropriate multibyte implementation as available to system.
* @param string Input string
* @return string Lower cased string
*/
if ( function_exists( 'mb_strtolower' ) ) {
function string_lower( $p_string ) {
return mb_strtolower( $p_string );
}
} else {
function string_lower( $p_string ) {
return strtolower( $p_string );
}
}

# ## --------------------
# Preserve spaces at beginning of lines.
# Lines must be separated by \n rather than <br />
Expand Down

0 comments on commit c675a01

Please sign in to comment.