ObjFW  Diff

Differences From Artifact [a4fa320751]:

To Artifact [a4348af620]:


1074
1075
1076
1077
1078
1079
1080
























































1081
1082
1083
1084
1085
1086
1087
				    exceptionWithClass: [self class]];

			cString[i] = (uint8_t)characters[i];
		}

		cString[i] = '\0';

























































		break;
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
				    exceptionWithClass: [self class]];

			cString[i] = (uint8_t)characters[i];
		}

		cString[i] = '\0';

		break;
	case OF_STRING_ENCODING_ISO_8859_15:
		cString = [object allocMemoryWithSize: length + 1];

		for (i = 0; i < length; i++) {
			of_unichar_t c = characters[i];

			switch (c) {
			case 0xA4:
			case 0xA6:
			case 0xA8:
			case 0xB4:
			case 0xB8:
			case 0xBC:
			case 0xBD:
			case 0xBE:
				@throw [OFInvalidEncodingException
				    exceptionWithClass: [self class]];
			}

			if (c > 0xFF) {
				switch (c) {
				case 0x20AC:
					cString[i] = 0xA4;
					break;
				case 0x160:
					cString[i] = 0xA6;
					break;
				case 0x161:
					cString[i] = 0xA8;
					break;
				case 0x17D:
					cString[i] = 0xB4;
					break;
				case 0x17E:
					cString[i] = 0xB8;
					break;
				case 0x152:
					cString[i] = 0xBC;
					break;
				case 0x153:
					cString[i] = 0xBD;
					break;
				case 0x178:
					cString[i] = 0xBE;
					break;
				default:
					@throw [OFInvalidEncodingException
					    exceptionWithClass: [self class]];
				}
			} else
				cString[i] = (uint8_t)c;
		}

		cString[i] = '\0';

		break;
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}

1120
1121
1122
1123
1124
1125
1126

1127
1128
1129
1130
1131
1132
1133

			UTF8StringLength += len;
		}

		return UTF8StringLength;
	case OF_STRING_ENCODING_ASCII:
	case OF_STRING_ENCODING_ISO_8859_1:

		return [self length];
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}
}







>







1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190

			UTF8StringLength += len;
		}

		return UTF8StringLength;
	case OF_STRING_ENCODING_ASCII:
	case OF_STRING_ENCODING_ISO_8859_1:
	case OF_STRING_ENCODING_ISO_8859_15:
		return [self length];
	default:
		@throw [OFNotImplementedException
		    exceptionWithClass: [self class]
			      selector: _cmd];
	}
}