Last active
August 29, 2015 14:17
-
-
Save theodorosploumis/445204913545951213c9 to your computer and use it in GitHub Desktop.
Greek toUppercase converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* CodeIgniter String Helpers | |
* | |
* @package OpenReceptor CMS | |
* @subpackage Helpers | |
* @category Helpers | |
* @author Dimitris Krestos | |
* @link http://vdw.staytuned.gr | |
*/ | |
/** | |
* Greek string to uppercase | |
* Correctly converts greek letters to uppercase. | |
* @access public | |
* @param string | |
* @return string | |
*/ | |
if ( ! function_exists('grstrtoupper')) | |
{ | |
function grstrtoupper($string) { | |
$latin_check = '/[\x{0030}-\x{007f}]/u'; | |
if (preg_match($latin_check, $string)) | |
{ | |
$string = strtoupper($string); | |
} | |
$letters = array('α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω'); | |
$letters_accent = array('ά', 'έ', 'ή', 'ί', 'ό', 'ύ', 'ώ'); | |
$letters_upper_accent = array('Ά', 'Έ', 'Ή', 'Ί', 'Ό', 'Ύ', 'Ώ'); | |
$letters_upper_solvents = array('ϊ', 'ϋ'); | |
$letters_other = array('ς'); | |
$letters_to_uppercase = array('Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω'); | |
$letters_accent_to_uppercase = array('Α', 'Ε', 'Η', 'Ι', 'Ο', 'Υ', 'Ω'); | |
$letters_upper_accent_to_uppercase = array('Α', 'Ε', 'Η', 'Ι', 'Ο', 'Υ', 'Ω'); | |
$letters_upper_solvents_to_uppercase = array('Ι', 'Υ'); | |
$letters_other_to_uppercase = array('Σ'); | |
$lowercase = array_merge($letters, $letters_accent, $letters_upper_accent, $letters_upper_solvents, $letters_other); | |
$uppercase = array_merge($letters_to_uppercase, $letters_accent_to_uppercase, $letters_upper_accent_to_uppercase, $letters_upper_solvents_to_uppercase, $letters_other_to_uppercase); | |
$uppecase_string = str_replace($lowercase, $uppercase, $string); | |
return $uppecase_string; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment