Skip to content

Commit 5a4c7f6

Browse files
committed
Properly convert CP1252 filenames to uppercase
Replace invalid CP1252 characters with question mark
1 parent 6384074 commit 5a4c7f6

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

cp1252/cp1252.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ char getCP1252FromUnicode(uint32_t input) {
144144
return (char)input;
145145
}
146146
else {
147-
return '\x20'; // SPACE
147+
return '\x3F'; // QUESTION MARK
148148
}
149149
}
150150
}
@@ -274,4 +274,20 @@ char* getCP1252String(const char* input) {
274274
return ret;
275275
}
276276

277+
char toupperCP1252(char c) {
278+
if (c >= 'a' && c <= 'z') {
279+
c -= 32;
280+
}
281+
else if (c == '\x9A' || c == '\x9C' || c == '\x9E') {
282+
c -= 16;
283+
}
284+
else if ((c >= '\xE0' && c <= '\xF6') || (c >= '\xF8' && c <= '\xFE')) {
285+
c -= 32;
286+
}
287+
else if (c == '\xFF') {
288+
c = '\x9F';
289+
}
290+
return c;
291+
}
292+
277293
#endif //CP1252_INCLUDED

extract-xiso.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,11 +1568,8 @@ int avl_compare_key( const char *in_lhs, const char *in_rhs ) {
15681568
unsigned char a, b;
15691569

15701570
for ( ;; ) {
1571-
a = (unsigned char)*in_lhs++;
1572-
b = (unsigned char)*in_rhs++;
1573-
1574-
if ( a >= 'a' && a <= 'z' ) a -= 32; // uppercase(a);
1575-
if ( b >= 'a' && b <= 'z' ) b -= 32; // uppercase(b);
1571+
a = (unsigned char)toupperCP1252(*in_lhs++);
1572+
b = (unsigned char)toupperCP1252(*in_rhs++);
15761573

15771574
if ( a ) {
15781575
if ( b ) {

0 commit comments

Comments
 (0)