From 7b243074da3f4be6ed47426925f203c547c1c729 Mon Sep 17 00:00:00 2001 From: Eduardo Casino Date: Mon, 16 May 2022 20:12:19 +0200 Subject: Add support for windows host short file names --- unicode.h | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'unicode.h') 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 -- cgit v1.2.3