From c97be8dbb292b17fc0021b485c456d9f0cfd5ab1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Apr 2015 16:56:44 +0200 Subject: [PATCH] BeOS: implement charset conversion. --- BasiliskII/src/BeOS/extfs_beos.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/BasiliskII/src/BeOS/extfs_beos.cpp b/BasiliskII/src/BeOS/extfs_beos.cpp index 7ee4253b..5f5d7df2 100644 --- a/BasiliskII/src/BeOS/extfs_beos.cpp +++ b/BasiliskII/src/BeOS/extfs_beos.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include "extfs.h" @@ -458,3 +459,29 @@ bool extfs_rename(const char *old_path, const char *new_path) { return rename(old_path, new_path) == 0; } + +/* + * Strings (filenames) conversion + */ + +// Convert from the host OS filename encoding to MacRoman +const char *host_encoding_to_macroman(const char *filename) +{ + int32 state = 0; + static char buffer[512]; + int32 size = sizeof(buffer) - 1; + int32 insize = strlen(filename); + convert_from_utf8(B_MAC_ROMAN_CONVERSION, filename, &insize, buffer, &size, &state); + return buffer; +} + +// Convert from MacRoman to host OS filename encoding +const char *macroman_to_host_encoding(const char *filename) +{ + int32 state = 0; + static char buffer[512]; + int32 insize = strlen(filename); + int32 size = sizeof(buffer) - 1; + convert_to_utf8(B_MAC_ROMAN_CONVERSION, filename, &insize, buffer, &size, &state); + return buffer; +}