|
|
|
|
| 152 |
nsresult |
152 |
nsresult |
| 153 |
nsPrimitiveHelpers :: ConvertUnicodeToPlatformPlainText ( PRUnichar* inUnicode, PRInt32 inUnicodeLen, |
153 |
nsPrimitiveHelpers :: ConvertUnicodeToPlatformPlainText ( PRUnichar* inUnicode, PRInt32 inUnicodeLen, |
| 154 |
char** outPlainTextData, PRInt32* outPlainTextLen ) |
154 |
char** outPlainTextData, PRInt32* outPlainTextLen ) |
| 155 |
{ |
155 |
{ |
| 156 |
if ( !outPlainTextData || !outPlainTextLen ) |
156 |
if ( !outPlainTextData || !outPlainTextLen ) |
| 157 |
return NS_ERROR_INVALID_ARG; |
157 |
return NS_ERROR_INVALID_ARG; |
| 158 |
|
158 |
|
| 159 |
// Get the appropriate unicode encoder. We're guaranteed that this won't change |
159 |
// Get the appropriate unicode encoder. We're guaranteed that this won't change |
| 160 |
// through the life of the app so we can cache it. |
160 |
// through the life of the app so we can cache it. |
| 161 |
nsresult rv; |
161 |
nsresult rv = NS_OK; |
| 162 |
nsCOMPtr<nsIUnicodeEncoder> encoder; |
162 |
nsCOMPtr<nsIUnicodeEncoder> encoder; |
| 163 |
|
163 |
|
| 164 |
// get the charset |
164 |
// get the charset |
| 165 |
nsCAutoString platformCharset; |
165 |
nsCAutoString platformCharset; |
| 166 |
nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); |
166 |
nsCOMPtr <nsIPlatformCharset> platformCharsetService = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv); |
| 167 |
if (NS_SUCCEEDED(rv)) |
167 |
if (NS_SUCCEEDED(rv)) |
| 168 |
rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset); |
168 |
rv = platformCharsetService->GetCharset(kPlatformCharsetSel_PlainTextInClipboard, platformCharset); |
| 169 |
if (NS_FAILED(rv)) |
169 |
if (NS_FAILED(rv)) |
| 170 |
platformCharset.AssignLiteral("ISO-8859-1"); |
170 |
platformCharset.AssignLiteral("ISO-8859-1"); |