unicode


Update: ElStr.class.php goes to v1.2

php-iconThe PHP Class ElStr with usefull functions for modern greek unicode text manipulation, such as transcript greek to latin, or accent marks stripping is now updated to version 1.2

What’s new?

  • mixed case support for difthongs, etc:
    • μπ => mp or τζ => tz
    • Μπ => Mp or Τζ => Tz
    • μΠ => mP or τΖ => tZ
    • ΜΠ => MP or ΤΖ => TZ

  • Two new accent mark removal methods:
    • strtolower_no_accent($str) – that Convert unicode string to lower case, without accent marks for the greek letters
    • str_no_accent($str) – that Remove accent marks for the greek letters at passed unicode string (no any case convertion)

Examples

require('ElStr.class.php') ;
$txt = "Το μπαρμπουνάκι θέλει μπυρίτσα" ;
$elstrObj = new El_Str() ;

echo $elstrObj->to_latin($txt) ;
//echoes: To barmpounaki thelei byritsa

echo $elstrObj->strtoupper_no_accent($txt) ;
//echoes: ΤΟ ΜΠΑΡΜΠΟΥΝΑΚΙ ΘΕΛΕΙ ΜΠΥΡΙΤΣΑ

echo $elstrObj->strtolower_no_accent($txt) ;
//echoes: το μπαρμπουνακι θελει μπυριτσα

echo $elstrObj->str_no_accent($txt) ;
//echoes: Το μπαρμπουνακι θελει μπυριτσα

Downloads

Download v1.2      View Source


ElStr.class.php

php-iconA PHP Class with usefull functions for modern greek unicode text manipulation, such as transcript greek to latin, or upper case greek letters stripped from accent marks.

Functions
string to_latin($str)

  • Convert greek letters at the string to latins, as ISO:843 / ΕΛΟΤ:743 defines
  • $str string to convert
  • Returns converted string

string strtoupper_no_accent($str)

  • Convert unicode string to upper case, without accent marks for the greek letters
  • $str string to upper case convert
  • Returns converted string

bool is_upper($char, $notGreekException = false)

  • Check if $char is upper case
  • $char is the character for checking
  • If $notGreekException == true, throws exception when char is not greek
  • Returns true if $char is upper case, else false

bool is_lower($char, $notGreekException = false)

  • Check if $char is lower case
  • $char is the character for checking
  • If $notGreekException == true, throws exception when char is not greek
  • Returns true if $char is lower case, else false

Download      Frok it at Github

License
This project is free software, distributed under the terms & conditions of the FreeBSD License.


Unexpected PHP session_start() error

When you write PHP code with sessions, and without any apparent reason you got a message like

ERROR Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by…

and you are sure that the session_start() function is before any other code, or you don’t have made any other mistake, don’t start checking your code or make any changes at it.

Maybe it’s a problem with the file encoding. Using session_start() function, in a unicode encoded file mainly at MS Windows throws the above error, because many Windows programs using Unicode with BOM and add the bytes 0xEF, 0xBB, 0xBF at the start of any document. So, this sends the standard html header before the cookie and makes this the php statement invalid.

The solution is to change the file encoding to Unicode WITHOUT BOM. If you’re using Notepad++, just go the Encoding menu and make the appropriate selection, as shown in the image.