From b590bc49f9dc2f33ebc51026bf1d7a7e519de4ad Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Wed, 13 Apr 2016 14:05:34 +0000 Subject: Rewrite fl_encoding_latin1.cxx under the driver model. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11599 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Darwin/Fl_Darwin_System_Driver.H | 2 ++ src/fl_encoding_latin1.cxx | 29 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index ac08fd8f4..8ee7f7a84 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -59,6 +59,8 @@ public: virtual void newUUID(char *uuidBuffer); virtual char *preference_rootnode(Fl_Preferences *prefs, Fl_Preferences::Root root, const char *vendor, const char *application); + virtual const char *local_to_latin1(const char *t, int n); + virtual const char *latin1_to_local(const char *t, int n); }; #endif // FL_DARWIN_SYSTEM_DRIVER_H diff --git a/src/fl_encoding_latin1.cxx b/src/fl_encoding_latin1.cxx index f7adc3459..9e3d16cfc 100644 --- a/src/fl_encoding_latin1.cxx +++ b/src/fl_encoding_latin1.cxx @@ -16,13 +16,17 @@ // http://www.fltk.org/str.php // +#include "config_lib.h" #include +#include +#include #include #include #include "flstring.h" -#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform text encoding - +#ifdef FL_CFG_WIN_COCOA +#include "drivers/Darwin/Fl_Darwin_System_Driver.H" + // These function assume a western code page. If you need to support // scripts that are not part of this code page, you might want to // take a look at FLTK2, which uses utf8 for text encoding. @@ -67,7 +71,7 @@ static uchar roman2latin[128] = { static char *buf = 0; static int n_buf = 0; -const char *fl_latin1_to_local(const char *t, int n) +const char *Fl_Darwin_System_Driver::latin1_to_local(const char *t, int n) { if (n==-1) n = strlen(t); if (n<=n_buf) { @@ -88,7 +92,7 @@ const char *fl_latin1_to_local(const char *t, int n) return buf; } -const char *fl_local_to_latin1(const char *t, int n) +const char *Fl_Darwin_System_Driver::local_to_latin1(const char *t, int n) { if (n==-1) n = strlen(t); if (n<=n_buf) { @@ -109,19 +113,28 @@ const char *fl_local_to_latin1(const char *t, int n) return buf; } -#else +#endif -const char *fl_latin1_to_local(const char *t, int) +const char *Fl_System_Driver::latin1_to_local(const char *t, int) { return t; } -const char *fl_local_to_latin1(const char *t, int) +const char *Fl_System_Driver::local_to_latin1(const char *t, int) { return t; } -#endif +const char *fl_latin1_to_local(const char *t, int n) +{ + return Fl::system_driver()->latin1_to_local(t, n); +} + +const char *fl_local_to_latin1(const char *t, int n) +{ + return Fl::system_driver()->local_to_latin1(t, n); +} + // // End of "$Id$". -- cgit v1.2.3