RT 4.2.13 Documentation

RT::I18N

Go to latest version →

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 => ENTITY, Encoding => ENCODING, PreserveWords => BOOL, IsOut => BOOL

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'.

If PreserveWords is true, values in mime head will be decoded.(default is false)

Incoming and outgoing mails are handled differently, if IsOut is true(default is false), it'll be treated as outgoing mail, otherwise incomding mail:

incoming mail: 1) find encoding 2) if found then try to convert to utf-8 in croak mode, return if success 3) guess encoding 4) if guessed differently then try to convert to utf-8 in croak mode, return if success 5) mark part as application/octet-stream instead of falling back to any encoding

outgoing mail: 1) find encoding 2) if didn't find then do nothing, send as is, let MUA deal with it 3) if found then try to convert it to outgoing encoding in croak mode, return if success 4) do nothing otherwise, keep original encoding

This function doesn't return anything meaningful.

DecodeMIMEWordsToUTF8 $raw

An utility method which mimics MIME::Words::decode_mimewords, but only limited functionality. Despite its name, this function returns the bytes of the string, in UTF-8.

_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 MIMEHead => HEAD, From => OLD_ENCODING, To => NEW_Encoding, PreserveWords => BOOL, IsOut => BOOL

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

EncodeFromToWithCroak $string, $from, $to

Try to encode string from encoding $from to encoding $to in croak mode

return (1, $encoded_string) if success, otherwise (0, $error)

← Back to index