- NAME
  - Init
  - encoding
  - SetMIMEEntityToUTF8 $entity
  - IsTextualContentType $type
  - SetMIMEEntityToEncoding $entity, $encoding
  - DecodeMIMEWordsToUTF8 $raw
  - _FindOrGuessCharset MIME::Entity, $head_only
  - _GuessCharset STRING
  - _CanonicalizeCharset NAME
  - SetMIMEHeadToEncoding HEAD OLD_CHARSET NEW_CHARSET

# NAME

RT::I18N - a base class for localization of RT

## Init

Initializes the lexicons used for localization.

## encoding

Returns the encoding of the current lexicon, as yanked out of __ContentType's "charset" field. If it can't find anything, it returns 'ISO-8859-1'

## SetMIMEEntityToUTF8 $entity

An utility function which will try to convert entity body into utf8. It's now a wrap-up of SetMIMEEntityToEncoding($entity, 'utf-8').

## IsTextualContentType $type

An utility function that determines whether $type is textual, meaning that it can sensibly be converted to Unicode text.

Currently, it returns true iff $type matches this regular expression (case-insensitively):

        ^(?:text/(?:plain|html)|message/rfc822)\b

## SetMIMEEntityToEncoding $entity, $encoding

An utility function which will try to convert entity body into specified charset encoding (encoded as octets, *not* unicode-strings). It will iterate all the entities in $entity, and try to convert each one into specified charset if whose Content-Type is 'text/plain'.

This function doesn't return anything meaningful.

## DecodeMIMEWordsToUTF8 $raw

An utility method which mimics MIME::Words::decode_mimewords, but only limited functionality. This function returns an utf-8 string.

It returns the decoded string, or the original string if it's not encoded. Since the subroutine converts specified string into utf-8 charset, it should not alter a subject written in English.

Why not use MIME::Words directly? Because it fails in RT when I tried. Maybe it's ok now.

## _FindOrGuessCharset MIME::Entity, $head_only

When handed a MIME::Entity will first attempt to read what charset the message is encoded in. Failing that, will use Encode::Guess to try to figure it out

If $head_only is true, only guesses charset for head parts. This is because header's encoding (e.g. filename="...") may be different from that of body's.

## _GuessCharset STRING

use Encode::Guess to try to figure it out the string's encoding.

## _CanonicalizeCharset NAME

canonicalize charset, return lowercase version. special cases are: gb2312 => gbk, utf8 => utf-8

## SetMIMEHeadToEncoding HEAD OLD_CHARSET NEW_CHARSET

Converts a MIME Head from one encoding to another. This totally violates the RFC. We should never need this. But, Surprise!, MUAs are badly broken and do this kind of stuff all the time

← Back to index