[go: nahoru, domu]

Open Bug 32848 Opened 25 years ago Updated 2 years ago

optimize code for 7bit check mail body

Categories

(MailNews Core :: Internationalization, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: nhottanscp, Unassigned)

Details

7 bit check mail body is used to relabel charset and transfer encoding as 
us-ascii, 7bit when the main body only contains characters in us-ascii range.
Currently, the function is used which converts data to unicode and check each 
character if greater than 127.
The code below was provided by ftang which does not do the unicode conversion 
but check charset specific marks (e.g. escape 0x1B).

PRBool ContainOnlyAscii(const char* charset, const char* data, PRInt32 size) 
{ 
    if( strncmp(charset, "ISO-2022", 8) == 0) { // ISO-2022-JP, ISO-2022-CN, 
ISO-2022-KR 
        for(char* p = data, PRInt32 i=0; i < size; i++, p++) { 
            if( 0x1b == *p) // searching for ESC 
                return PR_FALSE; 
       } 
    } else if( strcmp(charset, "HZ-GB-2312") == 0) { 
        for(char* p = data, PRInt32 i=0; i < size-1; i++, p++) 
            if(( '~' == *p) && ( '{' == *(p+1))) // searching for ~{ 
                return PR_FALSE; 
   } else { 
        for(char* p = data, PRInt32 i=0; i < size; i++, p++) 
            if( 0x80 & *p) // searching for 8 bits data 
                return PR_FALSE; 
  } 
  return PR_TRUE; 
}
Status: NEW → ASSIGNED
Target Milestone: M17
Target Milestone: M17 → Future
QA contact to ji.
QA Contact: momoi → ji
Product: MailNews → Core
Product: Core → MailNews Core
QA Contact: ji → i18n
Assignee: nhottanscp → nobody
Severity: normal → enhancement
Status: ASSIGNED → NEW
Priority: P3 → --
Target Milestone: Future → ---
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.