ObjFW  Diff

Differences From Artifact [469e0664e7]:

To Artifact [0a1b003490]:


20
21
22
23
24
25
26

27
28
29
30
31
32
33

#import "OFLocalization.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"

#import "OFInvalidArgumentException.h"


static OFLocalization *sharedLocalization = nil;

@implementation OFLocalization
@synthesize language = _language, territory = _territory, encoding = _encoding;
@synthesize decimalPoint = _decimalPoint;








>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#import "OFLocalization.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"

static OFLocalization *sharedLocalization = nil;

@implementation OFLocalization
@synthesize language = _language, territory = _territory, encoding = _encoding;
@synthesize decimalPoint = _decimalPoint;

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

128
129
130
131
132
133
134
		if ((tmp = strrchr(locale, '@')) != NULL)
			*tmp = '\0';

		/* Encoding */
		if ((tmp = strrchr(locale, '.')) != NULL) {
			*tmp++ = '\0';

			tmpLen = strlen(tmp);
			for (size_t i = 0; i < tmpLen; i++)
				tmp[i] = of_ascii_tolower(tmp[i]);

			if (strcmp(tmp, "utf8") == 0 ||
			    strcmp(tmp, "utf-8") == 0)
				_encoding = OF_STRING_ENCODING_UTF_8;
			else if (strcmp(tmp, "ascii") == 0 ||
			    strcmp(tmp, "us-ascii") == 0)
				_encoding = OF_STRING_ENCODING_ASCII;
			else if (strcmp(tmp, "iso8859-1") == 0 ||
			    strcmp(tmp, "iso-8859-1") == 0 ||
			    strcmp(tmp, "iso_8859-1") == 0)
				_encoding = OF_STRING_ENCODING_ISO_8859_1;
			else if (strcmp(tmp, "iso8859-2") == 0 ||
			    strcmp(tmp, "iso-8859-2") == 0 ||
			    strcmp(tmp, "iso_8859-2") == 0)
				_encoding = OF_STRING_ENCODING_ISO_8859_2;
			else if (strcmp(tmp, "iso8859-15") == 0 ||
			    strcmp(tmp, "iso-8859-15") == 0 ||
			    strcmp(tmp, "iso_8859-15") == 0)
				_encoding = OF_STRING_ENCODING_ISO_8859_15;
			/* Windows and DJGPP use a codepage */
			else if (strcmp(tmp, "1251") == 0)
				_encoding = OF_STRING_ENCODING_WINDOWS_1251;
			else if (strcmp(tmp, "1252") == 0)
				_encoding = OF_STRING_ENCODING_WINDOWS_1252;
			else if (strcmp(tmp, "437") == 0)
				_encoding = OF_STRING_ENCODING_CODEPAGE_437;
			else if (strcmp(tmp, "850") == 0)
				_encoding = OF_STRING_ENCODING_CODEPAGE_850;
			else if (strcmp(tmp, "858") == 0)
				_encoding = OF_STRING_ENCODING_CODEPAGE_858;

		}

		/* Territory */
		if ((tmp = strrchr(locale, '_')) != NULL) {
			*tmp++ = '\0';

			tmpLen = strlen(tmp);







<
<
<
|
<
<
|
<
<
|
|
<
<
|
<
|
<
|
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
>







89
90
91
92
93
94
95



96


97


98
99


100

101

102



103











104
105
106
107
108
109
110
111
		if ((tmp = strrchr(locale, '@')) != NULL)
			*tmp = '\0';

		/* Encoding */
		if ((tmp = strrchr(locale, '.')) != NULL) {
			*tmp++ = '\0';




			@try {


				const of_string_encoding_t ascii =


				    OF_STRING_ENCODING_ASCII;



				_encoding = of_string_parse_encoding([OFString

				    stringWithCString: tmp

					     encoding: ascii]);



			} @catch (OFInvalidEncodingException *e) {











			}
		}

		/* Territory */
		if ((tmp = strrchr(locale, '_')) != NULL) {
			*tmp++ = '\0';

			tmpLen = strlen(tmp);