Posted By

fackz on 03/18/09


Tagged

special characters uppercase uppercasing


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fackz


Uppercasing with special characters


 / Published in: PHP
 

ISO-8859-1 (Latin 1) full with all special characters: results in

TRY THIS: ÄÖÜß

  1. <?php
  2. function fullUpper($str){
  3. // convert to entities
  4. $subject = htmlentities($str,ENT_QUOTES);
  5. $pattern = '/&([a-z])(uml|acute|circ';
  6. $pattern.= '|tilde|ring|elig|grave|slash|horn|cedil|th);/e';
  7. $replace = "'&'.strtoupper('\\1').'\\2'.';'";
  8. $result = preg_replace($pattern, $replace, $subject);
  9. // convert from entities back to characters
  10. $htmltable = get_html_translation_table(HTML_ENTITIES);
  11. foreach($htmltable as $key => $value) {
  12. $result = ereg_replace(addslashes($value),$key,$result);
  13. }
  14. return(strtoupper($result));
  15. }
  16.  
  17. echo fullUpper("try this: äöüß");
  18. ?>

Report this snippet  

You need to login to post a comment.