[TYPO3-dev] MySQL First Letter and Umlauts
Martin Kutschker
martin.kutschker-n0spam at no5pam-blackbox.net
Fri Oct 26 18:43:24 CEST 2007
Steffen Kamper schrieb:
> Hi,
>
> i need a tip for an alphabetic List in mySQL (all in utf8).
>
> I did this (for drwiki)
> SELECT DISTINCT keyword,ASCII(UPPER(SUBSTRING(keyword,1,1))) letter FROM
> `tx_drwiki_pages` ORDER BY letter
>
> This works fine until the keyword starts with Umlaut, e.g. ÄÖÜ
> The strange is that Ä results in ASCII 195, but it is 196 ...
ASCII will return the numeric value of the first byte (not character),
so it'll return always 195 for all umlauts. The reason is that in utf8
multibyte characters start with a lead in that deontes the number of
characters. For two byte characters it's 195.
Try
SET NAMES utf8;
select ascii('Ä');
select ord('Ä');
select ascii(convert('Ä' using latin1));
select ord(convert('Ä' using latin1));
check the results and have a look a the Mysql documentation.
Masi
More information about the TYPO3-dev
mailing list