r91061 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91060‎ | r91061 | r91062 >
Date:09:22, 29 June 2011
Author:ialex
Status:ok
Tags:
Comment:
Removed code2utf() and replaced with codepointToUtf8() to reduce code duplication since they do exactely the same thing
Modified paths:
  • /trunk/phase3/includes/AjaxFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AjaxFunctions.php
@@ -36,7 +36,7 @@
3737 $pos++;
3838 $unicodeHexVal = substr ( $source, $pos, 4 );
3939 $unicode = hexdec ( $unicodeHexVal );
40 - $decodedStr .= code2utf( $unicode );
 40+ $decodedStr .= codepointToUtf8( $unicode );
4141 $pos += 4;
4242 } else {
4343 // we have an escaped ascii character
@@ -56,30 +56,3 @@
5757
5858 return $decodedStr;
5959 }
60 -
61 -/**
62 - * Function coverts number of utf char into that character.
63 - * Function taken from: http://www.php.net/manual/en/function.utf8-encode.php#49336
64 - *
65 - * @param $num Integer
66 - * @return utf8char
67 - */
68 -function code2utf( $num ) {
69 - if ( $num < 128 ) {
70 - return chr( $num );
71 - }
72 -
73 - if ( $num < 2048 ) {
74 - return chr( ( $num >> 6 ) + 192 ) . chr( ( $num&63 ) + 128 );
75 - }
76 -
77 - if ( $num < 65536 ) {
78 - return chr( ( $num >> 12 ) + 224 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 );
79 - }
80 -
81 - if ( $num < 2097152 ) {
82 - return chr( ( $num >> 18 ) + 240 ) . chr( ( ( $num >> 12 )&63 ) + 128 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 );
83 - }
84 -
85 - return '';
86 -}

Status & tagging log