codepointToUtf8(): Throw exception rather than calling die()
authorKevin Israel <pleasestand@live.com>
Sat, 31 Jan 2015 08:15:36 +0000 (03:15 -0500)
committerKevin Israel <pleasestand@live.com>
Sat, 31 Jan 2015 08:27:58 +0000 (03:27 -0500)
Change-Id: I0f2c05be95d34e069a3e9965f581d2adfc0a1b9d

includes/libs/normal/UtfNormalUtil.php

index 6c925df..ae88e73 100644 (file)
 
 /**
  * Return UTF-8 sequence for a given Unicode code point.
- * May die if fed out of range data.
  *
  * @param $codepoint Integer:
  * @return String
+ * @throws InvalidArgumentException if fed out of range data.
  * @public
  */
 function codepointToUtf8( $codepoint ) {
@@ -56,8 +56,7 @@ function codepointToUtf8( $codepoint ) {
                        chr( $codepoint & 0x3f | 0x80 );
        }
 
-       echo "Asked for code outside of range ($codepoint)\n";
-       die( -1 );
+       throw new InvalidArgumentException( "Asked for code outside of range ($codepoint)" );
 }
 
 /**
@@ -67,6 +66,7 @@ function codepointToUtf8( $codepoint ) {
  *
  * @param $sequence String
  * @return String
+ * @throws InvalidArgumentException if fed out of range data.
  * @private
  */
 function hexSequenceToUtf8( $sequence ) {