|
@@ 64-71 (lines=8) @@
|
| 61 |
|
*/ |
| 62 |
|
public static function to_ascii($string) { |
| 63 |
|
// Step 1: Check if the string is already ASCII |
| 64 |
|
if (self::is_ascii($string)) { |
| 65 |
|
// Skip to step 7 |
| 66 |
|
if (strlen($string) < 64) { |
| 67 |
|
return $string; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
throw new Requests_Exception('Provided string is too long', 'idna.provided_too_long', $string); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
// Step 2: nameprep |
| 74 |
|
$string = self::nameprep($string); |
|
@@ 78-85 (lines=8) @@
|
| 75 |
|
|
| 76 |
|
// Step 3: UseSTD3ASCIIRules is false, continue |
| 77 |
|
// Step 4: Check if it's ASCII now |
| 78 |
|
if (self::is_ascii($string)) { |
| 79 |
|
// Skip to step 7 |
| 80 |
|
if (strlen($string) < 64) { |
| 81 |
|
return $string; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
throw new Requests_Exception('Prepared string is too long', 'idna.prepared_too_long', $string); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
// Step 5: Check ACE prefix |
| 88 |
|
if (strpos($string, self::ACE_PREFIX) === 0) { |