Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-03 06:07:27

polkazebra
New Member
From: Tokyo, JAPAN
Registered: 2005-10-03
Posts: 3

[issue] ucfirst() garbles Japanese characters

Hi,
I just tried out textpattern 4.0.1 and found two cosmetic glitches concerning Japanese characters.
1)
In txp_prefs.php there are two places where
echo tr(tdcs(hed(ucfirst(gTxt($a[‘event’])),1),3));
appear in code.
This ucfirst() garbles Japanese characters since there is no such thing as “upper case” letters in the language.
Fix:
Just change the two occurences to
echo tr(tdcs(hed(gTxt($a[‘event’]),1),3));
and the characters render fine.
2)
In txp_category.php, to canonicalize(?) the category names,
$name = preg_replace(“/[^[:alnum:]\-_]/”, “”, str_replace(” “,”-”,$name));
appear.
This does not work with Japanese characters.
I suspect the [:alnum:] part in regex.
Fix:
Just make categories with dummy alphabet names and then change their titles in database using tools such as phpMyAdmin.

Last edited by polkazebra (2005-10-03 06:10:15)

Offline

#2 2005-10-03 07:28:11

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [issue] ucfirst() garbles Japanese characters

This ucfirst() garbles Japanese characters since there is no such thing as “upper case” letters in the language.

It shouldn’t do any harm if the locale setting is correct (at least that’s what the manual says).

What’s your locale? (admin > diagnostics)


Alex

Offline

#3 2005-10-03 16:34:43

polkazebra
New Member
From: Tokyo, JAPAN
Registered: 2005-10-03
Posts: 3

Re: [issue] ucfirst() garbles Japanese characters

Thank you for your quick response.
Texpattern diagnostic_info tab says as follows :

php_version: 5.0.5
magic_quotes: 1/0
MySQL: 4.1.14-log
locale: ja_JP.UTF-8
server: Apache/2.0.54 (Unix) DAV/2 mod_fastcgi/2.4.2 PHP/5.0.5
apache_version: Apache/2.0.54 (Unix) DAV/2 mod_fastcgi/2.4.2 PHP/5.0.5

So my locale is ja_JP.UTF-8.

Offline

#4 2005-10-03 21:50:04

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [issue] ucfirst() garbles Japanese characters

So my locale is ja_JP.UTF-8.

Ah, the manual is wrong. Surprise.


Alex

Offline

#5 2005-10-04 02:48:32

polkazebra
New Member
From: Tokyo, JAPAN
Registered: 2005-10-03
Posts: 3

Re: [issue] ucfirst() garbles Japanese characters

I think I found a solution for the ucfirst problem :

Change
echo tr(tdcs(hed(ucfirst(gTxt($a[‘event’])),1),3));
to
echo tr(tdcs(hed(mb_convert_case(gTxt($a[‘event’]),MB_CASE_TITLE),1),3));
.
Description of mb_convert_case is found at
http://www.php.net/manual/en/function.mb-convert-case.php
.
This function requires PHP 4.3 and above but works perfectly, i.e.,
when I set my language to English the items appear properly capitalized,
when I set it to Japanese the first letter renders without being messed up.

Last edited by polkazebra (2005-10-04 02:50:46)

Offline

#6 2005-10-04 04:06:19

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [issue] ucfirst() garbles Japanese characters

mbstring is an optional extension, so we can’t do this in the core (at least not without checking for mbstring first).


Alex

Offline

#7 2005-10-04 04:21:59

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [issue] ucfirst() garbles Japanese characters

> “Just make categories with dummy alphabet names and then change their titles in database using tools such as phpMyAdmin.”

Textpattern already does this for you. Enter the dummy name, then once the category is created, click on that category’s link. It will take you to a page where you can re-define the name and title.

Offline

Board footer

Powered by FluxBB