public void setTargetEncoding (final String sTargetEncoding) { // Throws an exception on an illegal charset CharsetHelper.getCharsetFromName (sTargetEncoding); targetEncoding = sTargetEncoding; }
@Nonnull private Charset _getCharset () { final String sResponseEncoding = m_aDelegate.getCharacterEncoding (); final Charset aCharset = CharsetHelper.getCharsetFromNameOrDefault (sResponseEncoding, StandardCharsets.UTF_8); return aCharset; }
public void setCharacterEncoding (@Nullable final String sCharacterEncoding) { setCharacterEncoding (CharsetHelper.getCharsetFromNameOrNull (sCharacterEncoding)); }
NonBlockingByteArrayInputStream aIS = new NonBlockingByteArrayInputStream (aBytes, 0, Math.min (EUnicodeBOM.getMaximumByteCount (), aBytes.length))) final InputStreamAndCharset aISC = CharsetHelper.getInputStreamAndCharsetFromBOM (aIS); if (aISC.hasBOM ()) nSearchOfs = aISC.getBOM ().getByteCount (); if (aISC.hasCharset ()) aParseCharset = aISC.getCharset ();
/** * Read a document from the specified input stream. The secure reading feature * has affect when using this method. * * @param aIS * The input stream to read. May not be <code>null</code>. * @return <code>null</code> in case reading fails. */ @Nullable default JAXBTYPE read (@Nonnull final InputStream aIS) { ValueEnforcer.notNull (aIS, "InputStream"); final InputStreamAndCharset aISAndBOM = CharsetHelper.getInputStreamAndCharsetFromBOM (aIS); if (aISAndBOM.hasCharset ()) { // BOM was found - read from Reader return read (StreamHelper.createReader (aISAndBOM.getInputStream (), aISAndBOM.getCharset ())); } // No BOM found - use the returned InputStream anyway, so that the pushed // back bytes are read return read (InputSourceFactory.create (aISAndBOM.getInputStream ())); }
final InputStreamAndCharset aISAndBOM = CharsetHelper.getInputStreamAndCharsetFromBOM (aISOrig); final InputStream aIS = aISAndBOM.getInputStream (); final Reader aReader = StreamHelper.createReader (aIS, aCharsetToUse); final ECSSVersion eVersion = aSettings.getCSSVersion ();
public HCCharsetSelect (@Nonnull final IHCRequestField aRF, final boolean bOnlyRegistered, @Nonnull final Locale aDisplayLocale) { super (aRF); for (final Charset aCharset : CharsetManager.getAllCharsets ().values ()) if (aCharset.isRegistered () || !bOnlyRegistered) addOption (aCharset.name (), aCharset.displayName (aDisplayLocale)); addOptionPleaseSelect (aDisplayLocale); } }
public void setSourceEncoding (final String sSourceEncoding) { // Throws an exception on an illegal charset CharsetHelper.getCharsetFromName (sSourceEncoding); sourceEncoding = sSourceEncoding; }
/** * @return The charset configured via {@link #ATTR_CHARSET} parameter or the * system default. Never <code>null</code>. */ @Nonnull protected Charset getCharset () { final String sCharsetName = attrs ().getAsString (ATTR_CHARSET); final Charset aCharset = CharsetHelper.getCharsetFromNameOrNull (sCharsetName); return aCharset != null ? aCharset : SystemHelper.getSystemCharset (); }
@Nonnull private Charset _getCharset () { final String sRequestEncoding = m_aDelegate.getCharacterEncoding (); return CharsetHelper.getCharsetFromNameOrDefault (sRequestEncoding, StandardCharsets.UTF_8); }
public void setEncoding (@Nullable final String sEncoding) { m_aEncoding = sEncoding == null ? null : CharsetHelper.getCharsetFromName (sEncoding); }
/** * Get the string with the charset defined in the content type. * * @param aFallbackCharset * The fallback charset to be used if the content type does not include * a charset. May not be <code>null</code>. * @return The string representation of the item. */ @Nonnull public String getStringWithFallback (@Nonnull final Charset aFallbackCharset) { final String sCharset = getCharSet (); final Charset aCharset = CharsetHelper.getCharsetFromNameOrDefault (sCharset, aFallbackCharset); return getString (aCharset); }
private void readObject (@Nonnull final ObjectInputStream in) throws IOException, ClassNotFoundException { m_aMimeType = (IMimeType) in.readObject (); m_bBase64Encoded = in.readBoolean (); m_aContent = (byte []) in.readObject (); final String sCharsetName = in.readUTF (); m_aCharset = CharsetHelper.getCharsetFromName (sCharsetName); m_sContent = (String) in.readObject (); }
final Charset aCharsetToUse = CharsetHelper.getCharsetFromNameOrDefault (m_sHeaderEncoding, SystemHelper.getSystemCharset ()); return aBAOS.getAsString (aCharsetToUse);
public void setCharacterEncoding (@Nullable final String sCharacterEncoding) { setCharacterEncoding (sCharacterEncoding == null ? null : CharsetHelper.getCharsetFromName (sCharacterEncoding)); }
public final void setEncoding (@Nonnull @Nonempty final String sEncoding) { ValueEnforcer.notEmpty (sEncoding, "Encoding"); // Throws IllegalArgumentException in case it is unknown CharsetHelper.getCharsetFromName (sEncoding); m_sEncoding = sEncoding; }
public void writeStartDocument (@Nonnull final String sEncoding, @Nullable final String sVersion) throws XMLStreamException { writeStartDocument (CharsetHelper.getCharsetFromName (sEncoding), EXMLVersion.getFromVersionOrNull (sVersion)); }
/** * @return The charset defined for this request. May be <code>null</code> if * none is present; */ @Nullable default Charset getCharset () { final String sEncoding = getRequest ().getCharacterEncoding (); return StringHelper.hasNoText (sEncoding) ? null : CharsetHelper.getCharsetFromName (sEncoding); }
@Nonnull @ContainsSoftMigration public EmailAttachment convertToNative (@Nonnull final IMicroElement eAttachment) { final String sFilename = eAttachment.getAttributeValue (ATTR_FILENAME); final String sCharset = eAttachment.getAttributeValue (ATTR_CHARSET); final Charset aCharset = sCharset == null ? null : CharsetHelper.getCharsetFromName (sCharset); String sContentType = eAttachment.getAttributeValue (ATTR_CONTENT_TYPE); if (sContentType == null) { // Soft migration 8.6.3 sContentType = FileTypeMap.getDefaultFileTypeMap ().getContentType (sFilename); } final String sDisposition = eAttachment.getAttributeValue (ATTR_DISPOSITION); EEmailAttachmentDisposition eDisposition = EEmailAttachmentDisposition.getFromIDOrNull (sDisposition); if (eDisposition == null) { // migration eDisposition = EmailAttachment.DEFAULT_DISPOSITION; } final byte [] aContent = Base64.safeDecode (eAttachment.getTextContent ()); return new EmailAttachment (sFilename, aContent, aCharset, sContentType, eDisposition); } }
Charset aCharset = null; if (sCharset != null) aCharset = CharsetHelper.getCharsetFromName (sCharset);