Uppercasing with special characters


/ Published in: PHP
Save to your folder(s)

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

TRY THIS: ÄÖÜß


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.