Commit 1fd91c3b authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: clean-up string utility

parent f690d54a
/***************************************************************************** /*****************************************************************************
* StringUtility.h: MacOS X interface module * StringUtility.h: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN * Copyright (C) 2002-2014 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -35,10 +35,7 @@ ...@@ -35,10 +35,7 @@
#define B64DecNSStr(s) [[VLCStringUtility sharedInstance] b64Decode: s] #define B64DecNSStr(s) [[VLCStringUtility sharedInstance] b64Decode: s]
#define B64EncAndFree(s) [[VLCStringUtility sharedInstance] b64EncodeAndFree: s] #define B64EncAndFree(s) [[VLCStringUtility sharedInstance] b64EncodeAndFree: s]
inline NSString *toNSStr(const char *str) { NSString *toNSStr(const char *str);
return str != NULL ? [NSString stringWithUTF8String:str] : @"";
}
unsigned int CocoaKeyToVLC(unichar i_key); unsigned int CocoaKeyToVLC(unichar i_key);
@interface VLCStringUtility : NSObject @interface VLCStringUtility : NSObject
......
/***************************************************************************** /*****************************************************************************
* StringUtility.m: MacOS X interface module * StringUtility.m: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN * Copyright (C) 2002-2014 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -55,24 +55,23 @@ static VLCStringUtility *_o_sharedInstance = nil; ...@@ -55,24 +55,23 @@ static VLCStringUtility *_o_sharedInstance = nil;
- (NSString *)localizedString:(const char *)psz - (NSString *)localizedString:(const char *)psz
{ {
NSString * o_str = nil; NSString * stringObject = nil;
if (psz != NULL) { if (psz != NULL) {
o_str = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding]; stringObject = [NSString stringWithCString: _(psz) encoding:NSUTF8StringEncoding];
if (o_str == NULL) { if (stringObject == NULL) {
msg_Err(VLCIntf, "could not translate: %s", psz); msg_Err(VLCIntf, "could not translate: %s", psz);
return(@""); return @"";
} }
} else { } else
return(@""); return @"";
}
return(o_str); return stringObject;
} }
/* i_width is in pixels */ /* i_width is in pixels */
- (NSString *)wrapString: (NSString *)o_in_string toWidth: (int) i_width - (NSString *)wrapString:(NSString *)o_in_string toWidth:(int)i_width
{ {
NSMutableString *o_wrapped; NSMutableString *o_wrapped;
NSString *o_out_string; NSString *o_out_string;
...@@ -208,6 +207,12 @@ unsigned int CocoaKeyToVLC(unichar i_key) ...@@ -208,6 +207,12 @@ unsigned int CocoaKeyToVLC(unichar i_key)
return (unsigned int)i_key; return (unsigned int)i_key;
} }
/* takes a good old const c string and converts it to NSString without UTF8 loss */
NSString *toNSStr(const char *str) {
return str != NULL ? [NSString stringWithUTF8String:str] : @"";
}
/* /*
* Converts VLC key string to a prettified version, for hotkey settings. * Converts VLC key string to a prettified version, for hotkey settings.
* The returned string adapts similar how its done within the cocoa framework when setting this * The returned string adapts similar how its done within the cocoa framework when setting this
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment