Java Code Examples for sun.net.idn.Punycode#decode()
The following examples show how to use
sun.net.idn.Punycode#decode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PunycodeTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 2
Source File: PunycodeTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 3
Source File: PunycodeTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 4
Source File: PunycodeTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 5
Source File: PunycodeTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 6
Source File: PunycodeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 7
Source File: PunycodeTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 8
Source File: PunycodeTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public String testDecoding(String inputS) { char input[] = new char[0]; int pp; StringBuffer output; /* Read the Punycode input string and convert to ASCII: */ if (inputS.length() <= ace_max_length+2) { input = inputS.toCharArray(); } else { fail(invalid_input, inputS); } input_length = input.length; /* Decode: */ output_length[0] = unicode_max_length; try { output = Punycode.decode((new StringBuffer()).append(input, 0, input_length), case_flags); } catch (Exception e) { fail(invalid_input, inputS); // never reach here, just to make compiler happy return null; } /* Output the result: */ StringBuffer result = new StringBuffer(); for (j = 0; j < output.length(); ++j) { result.append(String.format("%s+%04X ", case_flags[j] ? "U" : "u", (int)output.charAt(j) )); } testCount++; return result.substring(0, result.length() - 1); }
Example 9
Source File: IDN.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 10
Source File: IDN.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 11
Source File: IDN.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 12
Source File: IDN.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 13
Source File: IDN.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 14
Source File: IDN.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 15
Source File: IDN.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 16
Source File: IDN.java From JDKSourceCode1.8 with MIT License | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 17
Source File: IDN.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 18
Source File: IDN.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 19
Source File: IDN.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }
Example 20
Source File: IDN.java From jdk-1.7-annotated with Apache License 2.0 | 4 votes |
private static String toUnicodeInternal(String label, int flag) { boolean[] caseFlags = null; StringBuffer dest; // step 1 // find out if all the codepoints in input are ASCII boolean isASCII = isAllASCII(label); if(!isASCII){ // step 2 // perform the nameprep operation; flag ALLOW_UNASSIGNED is used here try { UCharacterIterator iter = UCharacterIterator.getInstance(label); dest = namePrep.prepare(iter, flag); } catch (Exception e) { // toUnicode never fails; if any step fails, return the input string return label; } } else { dest = new StringBuffer(label); } // step 3 // verify ACE Prefix if(startsWithACEPrefix(dest)) { // step 4 // Remove the ACE Prefix String temp = dest.substring(ACE_PREFIX_LENGTH, dest.length()); try { // step 5 // Decode using punycode StringBuffer decodeOut = Punycode.decode(new StringBuffer(temp), null); // step 6 // Apply toASCII String toASCIIOut = toASCII(decodeOut.toString(), flag); // step 7 // verify if (toASCIIOut.equalsIgnoreCase(dest.toString())) { // step 8 // return output of step 5 return decodeOut.toString(); } } catch (Exception ignored) { // no-op } } // just return the input return label; }