diff options
author | Eduardo Casino <mail@eduardocasino.es> | 2022-05-16 20:12:19 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2022-05-23 00:01:55 +0200 |
commit | 7b243074da3f4be6ed47426925f203c547c1c729 (patch) | |
tree | e200ebfbf6d3912458db78d26da4fb152bc1c4bb /unicode.h | |
parent | b8eb74ac1d31ffc382e654e19bba4e5e48f0001e (diff) | |
download | vbados-7b243074da3f4be6ed47426925f203c547c1c729.tar.gz vbados-7b243074da3f4be6ed47426925f203c547c1c729.zip |
Add support for windows host short file names
Diffstat (limited to 'unicode.h')
-rw-r--r-- | unicode.h | 42 |
1 files changed, 37 insertions, 5 deletions
@@ -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 |