private boolean isAvailabilityTestableForCharset(final String csName) { return Charset.forName(csName).canEncode() && !"COMPOUND_TEXT".equalsIgnoreCase(csName) && !"x-COMPOUND_TEXT".equalsIgnoreCase(csName) && !isOddBallLegacyCharsetThatDoesNotSupportFrenchCharacters(csName); }
private static CodePoints load(Charset c) { if (!c.canEncode()) throw new IllegalArgumentException("Charset " + c.name() + " does not support encoding"); return encodableCodePoints(c.newEncoder()); }
/** * @see Charset#canEncode() * @since 2.6 */ public boolean canEncode() { return charset.canEncode(); }
/** * @return * @see java.nio.charset.Charset#canEncode() */ public boolean canEncode() { return charset.canEncode(); }
/** * @return * @see java.nio.charset.Charset#canEncode() */ public boolean canEncode() { return charset.canEncode(); }
/** * @return * @see java.nio.charset.Charset#canEncode() */ public boolean canEncode() { return charset.canEncode(); }
public boolean isValidChar(char value) { return charset.canEncode(); }
StringByteString(String s, Charset charset) { this.string = Objects.requireNonNull(s); this.charset = Objects.requireNonNull(charset); if (!charset.canEncode()) { throw new IllegalArgumentException("Charset cannot encode: " + charset.name()); } this.byteHashCode = 0; this.byteLength = string.isEmpty() ? 0 : -1; }
public void startDocument() throws SAXException { Charset charSet = Charset.forName(getEncoding()); if (charSet.canEncode()) { charsetEncoder = charSet.newEncoder(); } }
/** * Returns the encoding used to read a file. If the specified * encoding is empty or <code>null</code>, or if the encoding is not valid * then the default encoding of the platform is returned. * * @param encoding * identifier of the character set * @return the default encoding for the specified encoding string */ public static String getEncoding(@CheckForNull final String encoding) { if (StringUtils.isNotBlank(encoding) && Charset.forName(encoding).canEncode()) { return encoding; } return Charset.defaultCharset().name(); } }
public static EciMode of(String data, String charsetName, int mode) { try { Charset charset = Charset.forName(charsetName); if (charset.canEncode() && charset.newEncoder().canEncode(data)) { return new EciMode(mode, charset); } else { return NONE; } } catch (UnsupportedCharsetException e) { return NONE; } }
/** * Returns the encoding used to read a file. If the specified * encoding is empty or <code>null</code>, or if the encoding is not valid * then the default encoding of the platform is returned. * * @param encoding * identifier of the character set * @return the default encoding for the specified encoding string */ public static String getEncoding(@CheckForNull final String encoding) { if (StringUtils.isNotBlank(encoding) && Charset.forName(encoding).canEncode()) { return encoding; } return Charset.defaultCharset().name(); } }
private static CodePoints load(Charset c) { if (!c.canEncode()) throw new IllegalArgumentException("Charset " + c.name() + " does not support encoding"); return encodableCodePoints(c.newEncoder()); }
public static boolean isValidFileName(String name) { if (name.length() == 0 || name.equals(".") || name.equals("..")) { return false; } for (int i = 0; i < name.length(); i++) { if (!isValidFileNameChar(name.charAt(i))) { return false; } } if (name.length() >= 3 && name.length() <= 4 && WINDOWS_NAMES.contains(name.toUpperCase(Locale.US))) { return false; } Charset cs = Charsets.UTF16; return cs.canEncode() && cs.newEncoder().canEncode(name); }
public static void addCharset(Charset charset) { Map<String, Charset> charsets = ImageSingletons.lookup(LocalizationSupport.class).charsets; charsets.put(charset.name().toLowerCase(), charset); for (String name : charset.aliases()) { charsets.put(name.toLowerCase(), charset); } /* Eagerly initialize all the tables necessary for decoding / encoding. */ charset.newDecoder(); if (charset.canEncode()) { charset.newEncoder(); } } }
public void startDocument() throws SAXException { String enc = getEncoding(); if (enc == null) { enc = "UTF-8"; } Charset charSet = Charset.forName(enc); if (charSet.canEncode()) { charsetEncoder = charSet.newEncoder(); } super.startDocument(); }
/** * Creates new {@code EncodingInfo} instance. */ public EncodingInfo(String ianaName, String javaName, int lastPrintable) { this.ianaName = ianaName; this.javaName = EncodingMap.getIANA2JavaMapping(ianaName); this.lastPrintable = lastPrintable; try { nioCharset = Charset.forName(this.javaName); if (nioCharset.canEncode()) nioCharEncoder = nioCharset.newEncoder(); } catch (IllegalCharsetNameException ie) { nioCharset = null; nioCharEncoder = null; } catch (UnsupportedCharsetException ue) { nioCharset = null; nioCharEncoder = null; } }
public void init(JMMarshallerImpl pController) throws JAXBException { super.init(pController); Charset charSet = Charset.forName(pController.getEncoding()); if (charSet.canEncode()) { charsetEncoder = charSet.newEncoder(); } }
@Nonnull public static byte [] getAsBytes (@Nonnull final String sText, @Nonnull final Charset aCharset) { ValueEnforcer.notNull (sText, "Text"); ValueEnforcer.notNull (aCharset, "Charset"); if (!aCharset.canEncode ()) throw new IllegalArgumentException ("Cannot encode to " + aCharset); // IFJDK5 return getAsBytes (sText, aCharset.name ()); // ELSE // return sText.getBytes (aCharset); // ENDIF }
public IBool canEncode(IString charset) { return values.bool(Charset.forName(charset.getValue()).canEncode()); }