Lines Matching +full:select +full:- +full:user -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

6 // +----------------------------------------------------------------------+
19 // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
21 // +----------------------------------------------------------------------+
39 * - www.nörgler.com
40 * - xn--nrgler-wxa
41 * - xn--brse-5qa.xn--knrz-1ra.info
43 * Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4
45 * You can select your preferred format via {@link set_paramter()}.
50 * @copyright 2004-2007 phlyLabs Berlin, http://phlylabs.de
66 var $_punycode_prefix = 'xn--';
89 var $_api_encoding = 'utf8'; // Default input charset is UTF-8
90 var $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
96 $this->slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount;
98 $this->NP = unserialize(file_get_contents(dirname(__FILE__).'/npdata.ser'));
100 $this->NP = unserialize(join('', file(dirname(__FILE__).'/npdata.ser')));
104 return $this->set_parameter($options);
111 * [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
112 * 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
113 * [overlong - Unicode does not allow unnecessarily long encodings of chars,
116 * [strict - true: strict mode, good for registration purposes - Causes errors
137 $this->_api_encoding = $v;
140 $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
145 $this->_allow_overlong = ($v) ? true : false;
148 $this->_strict_mode = ($v) ? true : false;
151 $this->_error('Set Parameter: Unknown option '.$k);
162 * @return string Decoded Domain name (UTF-8 or UCS-4)
175 $this->_error('Unknown encoding '.$one_time_encoding);
186 if ($this->_strict_mode) {
187 $this->_error('Only simple domain name parts can be handled in strict mode');
193 if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
194 $conv = $this->_decode($v);
201 if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
202 $conv = $this->_decode($v);
210 if ($this->_strict_mode) {
211 $this->_error('Only simple domain name parts can be handled in strict mode');
218 $conv = $this->_decode($v);
224 .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@')
233 $conv = $this->_decode($v);
239 $return = $this->_decode($input);
242 // The output is UTF-8 by default, other output formats need conversion here
244 switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
249 return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
252 return $this->_utf8_to_ucs4($return);
255 $this->_error('Unsupported output format');
261 * Encode a given UTF-8 domain name
262 * @param string Domain name (UTF-8 or UCS-4)
271 switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
273 $decoded = $this->_utf8_to_ucs4($decoded);
276 $decoded = $this->_ucs4_string_to_ucs4($decoded);
280 $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
306 if ($this->_strict_mode) {
307 $this->_error('Neither email addresses nor URLs are allowed in strict mode.');
314 $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin)));
318 $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin)));
329 $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
333 $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
338 if ($output = $this->_encode($decoded)) {
342 return $this->_ucs4_to_utf8($decoded);
353 return $this->_error;
363 if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
364 $this->_error('This is not a punycode string');
367 $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
370 $this->_error('The given encoded string was empty');
374 $delim_pos = strrpos($encoded, '-');
375 if ($delim_pos > strlen($this->_punycode_prefix)) {
376 for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
387 $bias = $this->_initial_bias;
389 $char = $this->_initial_n;
392 for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
393 $digit = $this->_decode_digit($encoded[$enco_idx++]);
395 $t = ($k <= $bias) ? $this->_tmin :
396 (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
398 $w = (int) ($w * ($this->_base - $t));
400 $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
406 for ($i = $deco_len; $i > $idx; $i--) {
407 $decoded[$i] = $decoded[($i - 1)];
412 return $this->_ucs4_to_utf8($decoded);
422 $extract = strlen($this->_punycode_prefix);
423 $check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix);
427 $this->_error('This is already a punycode string');
439 $this->_error('The given string does not contain encodable chars');
444 $decoded = $this->_nameprep($decoded);
456 // Will match [-0-9a-zA-Z]
466 $encoded = $this->_punycode_prefix.$encoded;
469 if ($codecount) $encoded .= '-';
471 // Now find and encode all non-basic code points
473 $cur_code = $this->_initial_n;
474 $bias = $this->_initial_bias;
479 for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) {
485 $delta += ($next_code - $cur_code) * ($codecount + 1);
493 for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
494 $t = ($k <= $bias) ? $this->_tmin :
495 (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
497 $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval()
498 $q = (int) (($q - $t) / ($this->_base - $t));
500 $encoded .= $this->_encode_digit($q);
501 $bias = $this->_adapt($delta, $codecount+1, $is_first);
519 $delta = intval($is_first ? ($delta / $this->_damp) : ($delta / 2));
521 for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) {
522 $delta = intval($delta / ($this->_base - $this->_tmin));
524 return intval($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew));
543 return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $this->_base));
552 $this->_error = $error;
572 if (in_array($v, $this->NP['map_nothing'])) continue;
575 if (in_array($v, $this->NP['prohibit']) || in_array($v, $this->NP['general_prohibited'])) {
576 $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
579 foreach ($this->NP['prohibit_ranges'] as $range) {
581 $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
588 foreach ($this->_hangul_decompose($v) as $out) {
592 } elseif (isset($this->NP['replacemaps'][$v])) {
593 foreach ($this->_apply_cannonical_ordering($this->NP['replacemaps'][$v]) as $out) {
601 $output = $this->_hangul_compose($output);
609 $class = $this->_get_combining_class($output[$i]);
612 $seq_len = $i - $last_starter;
613 $out = $this->_combine(array_slice($output, $last_starter, $seq_len));
615 // the now redundant non-starter(s)
620 $output[$j-1] = $output[$j];
625 $i--;
626 $out_len--;
627 $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i-1]);
647 $sindex = (int) $char - $this->_sbase;
648 if ($sindex < 0 || $sindex >= $this->_scount) {
652 $result[] = (int) $this->_lbase + $sindex / $this->_ncount;
653 $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount;
654 $T = intval($this->_tbase + $sindex % $this->_tcount);
655 if ($T != $this->_tbase) $result[] = $T;
675 $sindex = $last - $this->_sbase;
676 $lindex = $last - $this->_lbase;
677 $vindex = $char - $this->_vbase;
678 $tindex = $char - $this->_tbase;
680 if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount == 0)
681 && 0 <= $tindex && $tindex <= $this->_tcount) {
684 $result[(count($result) - 1)] = $last; // reset last
688 if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) {
690 $last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount;
691 $result[(count($result) - 1)] = $last; // reset last
709 return isset($this->NP['norm_combcls'][$char]) ? $this->NP['norm_combcls'][$char] : 0;
724 $last = $this->_get_combining_class(intval($input[0]));
725 for ($i = 0; $i < $size-1; ++$i) {
726 $next = $this->_get_combining_class(intval($input[$i+1]));
729 for ($j = $i + 1; $j > 0; --$j) {
730 if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break;
732 $input[$j] = intval($input[$j-1]);
733 $input[$j-1] = $t;
746 * Do composition of a sequence of starter and non-starter
754 foreach ($this->NP['replacemaps'] as $np_src => $np_target) {
772 * This converts an UTF-8 encoded string to its UCS-4 representation
773 * By talking about UCS-4 "strings" we mean arrays of 32bit integers representing
776 * The following UTF-8 encodings are supported:
785 * The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000
798 if ($v < 128) { // We found an ASCII char - put into stirng as is
802 $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
813 $v = ($v - 192) << 6;
816 $v = ($v - 224) << 12;
819 $v = ($v - 240) << 18;
822 $v = ($v - 248) << 24;
825 $v = ($v - 252) << 30;
827 $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
837 if (!$this->_allow_overlong && $test == 'range') {
840 $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
845 $v = ($v - 128) << ($next_byte * 6);
846 $output[($out_len - 1)] += $v;
847 --$next_byte;
849 $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
861 * Convert UCS-4 string into UTF-8 string
890 $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
898 * Convert UCS-4 array into UCS-4 string
914 * Convert UCS-4 strin into UCS-4 garray
924 $this->_error('Input UCS4 string is broken');
927 // Empty input - return empty output
929 for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
935 $output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
949 * [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
950 * 'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
951 * [overlong - Unicode does not allow unnecessarily long encodings of chars,
954 * [strict - true: strict mode, good for registration purposes - Causes errors
965 return $this->IC->set_parameters($option, $param);