aboutsummaryrefslogtreecommitdiff
path: root/unicode.h
diff options
context:
space:
mode:
authorEduardo Casino <mail@eduardocasino.es>2022-05-16 20:12:19 +0200
committerJavier <dev.git@javispedro.com>2022-05-23 00:01:55 +0200
commit7b243074da3f4be6ed47426925f203c547c1c729 (patch)
treee200ebfbf6d3912458db78d26da4fb152bc1c4bb /unicode.h
parentb8eb74ac1d31ffc382e654e19bba4e5e48f0001e (diff)
downloadvbados-7b243074da3f4be6ed47426925f203c547c1c729.tar.gz
vbados-7b243074da3f4be6ed47426925f203c547c1c729.zip
Add support for windows host short file names
Diffstat (limited to 'unicode.h')
-rw-r--r--unicode.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/unicode.h b/unicode.h
index 9e70895..81d187a 100644
--- a/unicode.h
+++ b/unicode.h
@@ -1,8 +1,5 @@
/*
- * VBSF - unix to DOS time conversion
- * Copyright (C) 2022 Javier S. Pedro
- *
- * unicode.h: Unicode conversion routines
+ * VBSF - Unicode conversion routines
* Copyright (C) 2011-2022 Eduardo Casino
*
* This program is free software; you can redistribute it and/or
@@ -212,4 +209,39 @@ cont:
}
-#endif
+// Returns true on success, false if any unsupported char is found
+//
+static bool utf16_to_local( TSRDATAPTR data, uint8_t *dst, uint16_t *src, uint16_t len )
+{
+ bool ret = true;
+ int i;
+ uint16_t cp;
+ uint8_t c;
+
+ for ( i = 0; i < len; ++i )
+ {
+ cp = src[i];
+
+ if ( cp < 0x80 )
+ {
+ *dst++ = ( uint8_t ) cp;
+ }
+ else
+ {
+ c = lookup_codepage( data, cp );
+ if ( c == '\0' )
+ {
+ c = '_';
+ ret = false;
+ }
+ *dst++ = c;
+ }
+ }
+
+ *dst = '\0';
+
+ return ret;
+
+}
+
+#endif // UNICODE_H