Fix window title encoding when getting it via AppleScript. b=448087 r=josh sr=roc

This commit is contained in:
Luis de la Rosa 2009-02-20 16:09:20 -05:00
Родитель 814bebc25e
Коммит 62bf95e767
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -426,8 +426,9 @@ void nsWindowUtils::GetCleanedWindowName(WindowPtr wind, char* outName, long max
baseWindow->GetTitle(getter_Copies(title));
ThrowErrIfNil(title, paramErr);
// convert to MacRoman, which is what AppleEvents expects
CFStringRef windowTitleCFString = ::CFStringCreateWithCharacters(kCFAllocatorDefault, title.get(), kCFStringEncodingUTF16);
// Convert window title to MacRoman, which is what AppleEvents expects
const char* cTitle = NS_ConvertUTF16toUTF8(title).get();
CFStringRef windowTitleCFString = ::CFStringCreateWithCString(kCFAllocatorDefault, (char *)cTitle, kCFStringEncodingUTF8);
if (windowTitleCFString) {
::CFStringGetCString(windowTitleCFString, outName, maxLen, kCFStringEncodingMacRoman);
outName[maxLen - 1] = '\0'; // in case it didn't get null terminated