01-06-2008 12:39 PM
mimetypeService.getContentCharsetFinder().getCharset(streamSupportingMark, type)
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
01-18-2008 09:00 AM
01-18-2008 09:00 AM
<bean id="charset.finder" class="org.alfresco.repo.content.encoding.ContentCharsetFinder">
<property name="defaultCharset">
<value>UTF-8</value>
</property>
<property name="mimetypeService">
<ref bean="mimetypeService"/>
</property>
<property name="charactersetFinders">
<list>
<bean class="org.alfresco.encoding.GuessEncodingCharsetFinder" />
<bean class="org.alfresco.encoding.HtmlCharsetFinder" />
</list>
</property>
</bean>
From the Javadocs:
/**
* Worker method for implementations to override. All exceptions will be reported and
* absorbed and <tt>null</tt> returned.
* <p>
* The interface contract is that the data buffer must not be altered in any way.
*
* @param buffer the buffer of data no bigger than the requested
* {@linkplain #getBestBufferSize() best buffer size}. This can,
* very efficiently, be turned into an <tt>InputStream</tt> using a
* <tt>ByteArrayInputStream<tt>.
* @return Returns the charset or <tt>null</tt> if an accurate conclusion
* is not possible
* @throws Exception Any exception, checked or not
*/
protected abstract Charset detectCharsetImpl(byte[] buffer) throws Exception;
All finders will be attempted, in order, until a non-null is returned. So, any contributed finders would be appreciated and attached to that list provided that they don't produce poor guesses: A null guess is better than an incorrect guess. You finder can also specialize in HTML and just return null for everything else.01-18-2008 09:04 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.