more unicode fixups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24438 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-01-31 12:04:46 +00:00
parent 38f4377214
commit 26792908cf
3 changed files with 21 additions and 21 deletions

View file

@ -34,10 +34,12 @@
- (NSMutableString *) dumpQue:(int)acount - (NSMutableString *) dumpQue:(int)acount
{ {
NSMutableString * output=[NSMutableString stringWithCString:"Dumping "]; NSMutableString * output;
int i=0; int i=0;
int c=[event_queue count]; int c=[event_queue count];
output = [NSMutableString stringWithCapacity: 1024];
[output appendString: @"Dumping "];
if (acount >=c || acount==0) if (acount >=c || acount==0)
acount=c; acount=c;
else else

View file

@ -1199,12 +1199,13 @@ printf("\n\n##############################################################\n");
- (NSString *) getNativeClassName: (HWND)hwnd - (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; return nil;
@ -1212,11 +1213,14 @@ printf("\n\n##############################################################\n");
- (NSString *) getWindowtext: (HWND)hwnd - (NSString *) getWindowtext: (HWND)hwnd
{ {
char * windowText[80];
int wsize = 80; int wsize = 80;
unichar windowText[wsize + 1];
if (GetWindowText(hwnd,(LPTSTR)windowText,wsize) > 0) if (GetWindowTextW(hwnd, windowText, wsize) > 0)
return [NSString stringWithCString: (char *)windowText length: wsize + 1]; {
return [NSString stringWithCharacters: windowText
length: wcslen(windowText)];
}
return nil; return nil;
} }

View file

@ -122,16 +122,14 @@ void add_font(NSMutableArray *fontDefs, NSString *fontName,
else else
traits |= NSUnitalicFontMask; traits |= NSUnitalicFontMask;
fontStyle = [[NSString alloc] initWithBytes: lpelfe->elfStyle fontStyle = [NSString stringWithCharacters: lpelfe->elfStyle
length: wcslen(lpelfe->elfStyle) length: wcslen(lpelfe->elfStyle)];
encoding: NSUnicodeStringEncoding];
fontDef = [NSArray arrayWithObjects: fontDef = [NSArray arrayWithObjects:
fontName, fontName,
fontStyle, fontStyle,
[NSNumber numberWithInt: weight], [NSNumber numberWithInt: weight],
[NSNumber numberWithUnsignedInt: traits], [NSNumber numberWithUnsignedInt: traits],
nil]; nil];
RELEASE(fontStyle);
[fontDefs addObject: fontDef]; [fontDefs addObject: fontDef];
} }
@ -140,12 +138,10 @@ int CALLBACK fontenum(ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme,
{ {
NSString *fontName; NSString *fontName;
fontName = [[NSString alloc] initWithBytes: lpelfe->elfFullName fontName = [NSString stringWithCharacters: lpelfe->elfFullName
length: wcslen(lpelfe->elfFullName) length: wcslen(lpelfe->elfFullName)];
encoding: NSUnicodeStringEncoding];
NSLog(@"Found font %@", fontName); NSLog(@"Found font %@", fontName);
add_font((NSMutableArray *)lParam, fontName, lpelfe, lpntme); add_font((NSMutableArray *)lParam, fontName, lpelfe, lpntme);
RELEASE(fontName);
return 1; return 1;
} }
@ -178,10 +174,8 @@ int CALLBACK fontfamilyenum(ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEX *lpntme,
NSMutableArray *fontDefs; NSMutableArray *fontDefs;
WIN32FontEnumerator *enumer = (WIN32FontEnumerator*)lParam; WIN32FontEnumerator *enumer = (WIN32FontEnumerator*)lParam;
fontName = AUTORELEASE([[NSString alloc] fontName = [NSString stringWithCharacters: lpelfe->elfFullName
initWithBytes: lpelfe->elfFullName length: wcslen(lpelfe->elfFullName)];
length: wcslen(lpelfe->elfFullName)
encoding: NSUnicodeStringEncoding]);
familyName = win32_font_family(fontName); familyName = win32_font_family(fontName);
fontDefs = [enumer->allFontFamilies objectForKey: familyName]; fontDefs = [enumer->allFontFamilies objectForKey: familyName];