From 26792908cf77703147e259564adbbd16c12736b2 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Wed, 31 Jan 2007 12:04:46 +0000 Subject: [PATCH] more unicode fixups git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24438 72102866-910b-0410-8b05-ffd578937521 --- Source/win32/GSDisplayServer_details.m | 6 ++++-- Source/win32/WIN32Server.m | 18 +++++++++++------- Source/winlib/WIN32FontEnumerator.m | 18 ++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Source/win32/GSDisplayServer_details.m b/Source/win32/GSDisplayServer_details.m index f611315..6cdbf36 100644 --- a/Source/win32/GSDisplayServer_details.m +++ b/Source/win32/GSDisplayServer_details.m @@ -34,10 +34,12 @@ - (NSMutableString *) dumpQue:(int)acount { - NSMutableString * output=[NSMutableString stringWithCString:"Dumping "]; - + NSMutableString * output; int i=0; int c=[event_queue count]; + + output = [NSMutableString stringWithCapacity: 1024]; + [output appendString: @"Dumping "]; if (acount >=c || acount==0) acount=c; else diff --git a/Source/win32/WIN32Server.m b/Source/win32/WIN32Server.m index d0e082b..db5cb49 100644 --- a/Source/win32/WIN32Server.m +++ b/Source/win32/WIN32Server.m @@ -1199,12 +1199,13 @@ printf("\n\n##############################################################\n"); - (NSString *) getNativeClassName: (HWND)hwnd { - char * windowType[80]; - UINT wsize =80; + UINT wsize = 80; + unichar windowType[wsize + 1]; - if (RealGetWindowClass(hwnd,(LPTSTR)windowType,wsize)>0) + if (RealGetWindowClassW(hwnd, windowType, wsize) > 0) { - return [NSString stringWithCString: (char *)windowType length: wsize+1]; + return [NSString stringWithCharacters: windowType + length: wcslen(windowType)]; } return nil; @@ -1212,11 +1213,14 @@ printf("\n\n##############################################################\n"); - (NSString *) getWindowtext: (HWND)hwnd { - char * windowText[80]; int wsize = 80; + unichar windowText[wsize + 1]; - if (GetWindowText(hwnd,(LPTSTR)windowText,wsize) > 0) - return [NSString stringWithCString: (char *)windowText length: wsize + 1]; + if (GetWindowTextW(hwnd, windowText, wsize) > 0) + { + return [NSString stringWithCharacters: windowText + length: wcslen(windowText)]; + } return nil; } diff --git a/Source/winlib/WIN32FontEnumerator.m b/Source/winlib/WIN32FontEnumerator.m index aa9ea65..41080b1 100644 --- a/Source/winlib/WIN32FontEnumerator.m +++ b/Source/winlib/WIN32FontEnumerator.m @@ -122,16 +122,14 @@ void add_font(NSMutableArray *fontDefs, NSString *fontName, else traits |= NSUnitalicFontMask; - fontStyle = [[NSString alloc] initWithBytes: lpelfe->elfStyle - length: wcslen(lpelfe->elfStyle) - encoding: NSUnicodeStringEncoding]; + fontStyle = [NSString stringWithCharacters: lpelfe->elfStyle + length: wcslen(lpelfe->elfStyle)]; fontDef = [NSArray arrayWithObjects: fontName, fontStyle, [NSNumber numberWithInt: weight], [NSNumber numberWithUnsignedInt: traits], nil]; - RELEASE(fontStyle); [fontDefs addObject: fontDef]; } @@ -140,12 +138,10 @@ int CALLBACK fontenum(ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme, { NSString *fontName; - fontName = [[NSString alloc] initWithBytes: lpelfe->elfFullName - length: wcslen(lpelfe->elfFullName) - encoding: NSUnicodeStringEncoding]; + fontName = [NSString stringWithCharacters: lpelfe->elfFullName + length: wcslen(lpelfe->elfFullName)]; NSLog(@"Found font %@", fontName); add_font((NSMutableArray *)lParam, fontName, lpelfe, lpntme); - RELEASE(fontName); return 1; } @@ -178,10 +174,8 @@ int CALLBACK fontfamilyenum(ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme, NSMutableArray *fontDefs; WIN32FontEnumerator *enumer = (WIN32FontEnumerator*)lParam; - fontName = AUTORELEASE([[NSString alloc] - initWithBytes: lpelfe->elfFullName - length: wcslen(lpelfe->elfFullName) - encoding: NSUnicodeStringEncoding]); + fontName = [NSString stringWithCharacters: lpelfe->elfFullName + length: wcslen(lpelfe->elfFullName)]; familyName = win32_font_family(fontName); fontDefs = [enumer->allFontFamilies objectForKey: familyName];