mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Fix for bug 182643. The data stored in the palm pilote uses ISO-Latin-1 and not UTF-8. Also, the addressbook name is in UTF-8. R=cavin, rdayal, SR=sspitzer
This commit is contained in:
parent
5be1ca4541
commit
2637e30f6e
@ -137,11 +137,11 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
|
||||
(server->dirType == PABDirectory))
|
||||
continue;
|
||||
|
||||
// server->description is represented in UTF8, we need to do some conversion...
|
||||
if(aIsUnicode) {
|
||||
// convert to unicode
|
||||
// convert to Unicode
|
||||
nsAutoString abName;
|
||||
nsCAutoString platformCharSet(nsMsgI18NFileSystemCharset());
|
||||
rv = ConvertToUnicode(platformCharSet.get(), server->description, abName);
|
||||
rv = ConvertToUnicode("UTF-8", server->description, abName);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
// add to the list
|
||||
@ -149,9 +149,15 @@ STDMETHODIMP CPalmSyncImp::nsGetABList(BOOL aIsUnicode, short * aABListCount,
|
||||
wcscpy(m_ServerDescList->lpszABDesc, abName.get());
|
||||
}
|
||||
else {
|
||||
// we are just typecasting ascii to unichar and back for the ascii description
|
||||
m_ServerDescList->lpszABDesc = (LPTSTR) CoTaskMemAlloc(sizeof(char) * (strlen(server->description)+1));
|
||||
strcpy((char*)m_ServerDescList->lpszABDesc, server->description);
|
||||
// we need to convert the description from UTF-8 to Unicode and then to ASCII
|
||||
nsAutoString abUName;
|
||||
rv = ConvertToUnicode("UTF-8", server->description, abUName);
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
nsCAutoString abName = NS_LossyConvertUCS2toASCII(abUName);
|
||||
|
||||
m_ServerDescList->lpszABDesc = (LPTSTR) CoTaskMemAlloc(sizeof(char) * (abName.Length()+1));
|
||||
strcpy((char*)m_ServerDescList->lpszABDesc, abName.get());
|
||||
}
|
||||
m_ServerDescList++;
|
||||
|
||||
|
@ -159,7 +159,7 @@ nsresult nsAbIPCCard::Copy(nsABCOMCardStruct * srcCard)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define CONVERT_ASSIGNTO_UNICODE(d, s) d.SetLength(0); if((char*) s) d=NS_ConvertUTF8toUCS2((char*)s);
|
||||
#define CONVERT_ASSIGNTO_UNICODE(d, s) d.SetLength(0); if((char*) s) d=NS_ConvertASCIItoUCS2((char*)s);
|
||||
|
||||
nsresult nsAbIPCCard::ConvertToUnicodeAndCopy(nsABCOMCardStruct * srcCard)
|
||||
{
|
||||
@ -684,7 +684,7 @@ void nsAbIPCCard::CopyValue(PRBool isUnicode, nsString & attribValue, LPTSTR * r
|
||||
}
|
||||
else {
|
||||
nsCAutoString cStr;
|
||||
cStr = NS_ConvertUCS2toUTF8(attribValue);
|
||||
cStr = NS_LossyConvertUCS2toASCII(attribValue);
|
||||
char * str = (char *) CoTaskMemAlloc(cStr.Length()+1);
|
||||
strcpy(str, cStr.get());
|
||||
*result = (LPTSTR) str;
|
||||
|
@ -127,8 +127,7 @@ nsAbPalmHotSync::nsAbPalmHotSync(PRBool aIsUnicode, PRUnichar * aAbDescUnicode,
|
||||
if(aIsUnicode)
|
||||
mAbName.Assign(aAbDescUnicode);
|
||||
else
|
||||
// mAbName.AssignWithConversion(aAbDesc);
|
||||
mAbName = NS_ConvertUTF8toUCS2(aAbDesc);
|
||||
mAbName = NS_ConvertASCIItoUCS2(aAbDesc);
|
||||
mAbName.Trim(" ");
|
||||
|
||||
mPalmCategoryId = aPalmCatID;
|
||||
@ -190,10 +189,9 @@ nsresult nsAbPalmHotSync::Initialize()
|
||||
if((server->PalmCategoryId > -1) && (mPalmCategoryId == server->PalmCategoryId))
|
||||
break;
|
||||
|
||||
// convert to unicode
|
||||
// convert from UTF-8 to unicode
|
||||
nsAutoString abName;
|
||||
nsCAutoString platformCharSet(nsMsgI18NFileSystemCharset());
|
||||
rv = ConvertToUnicode(platformCharSet.get(), server->description, abName);
|
||||
rv = ConvertToUnicode("UTF-8", server->description, abName);
|
||||
if(NS_FAILED(rv)) return rv ;
|
||||
|
||||
// if Palm category is not already assigned check the AB name
|
||||
|
Loading…
Reference in New Issue
Block a user