We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 738 - Suggestion
Summary: Suggestion
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: x86 All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-05 12:20 UTC by mosfet
Modified: 2009-09-26 03:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mosfet 2009-05-05 12:20:13 UTC
Hi,

Please read this message until then end and don't say no before ;-).
I am programming for 6 years now on window ce and symbian and there is something I ama really fed up with its ANSI/UTF16 conversion.
I have started a new frameworks that I hope will start to be useful in 1/2 years but until now I am using SDL for video handling.
Could it be possible to create a unicode aware version of SDL.
Actually I have already started to do it on my local copy of SDL, I have created a SDL_tchar.h :

#ifndef _SDL_tchar_h
#define _SDL_tchar_h

#if defined(_WIN32) ||defined(_WIN32_WCE) 

// For now we define as char
typedef TCHAR				SDL_Char;
#define SDL_strcpy                      _tcscpy
...
...
...
#else
typedef char				SDL_Char;
#define SDL_strcpy                      _strcpy
#endif


If you do something like that it will be compatible with all existing version of SDL because as long as UNICODE is not defined a SDL_Char will be a char.
But later on if you replace all strings "" by _T("") and char* by SDL_Char*, it will be possible to use UNICODE version on win and wince.

And Finally I would be able to do something like that :

LPCTSTR szFileName = myunicodeapi ( .... );
SDL_Load(szFileName);

instead of

char szFileNameA[MAX_PATH];
wcstombs(...)
SDL_Load(szFileNameA);


I have that kind of code verywhere and it's so ugly and could be easily handled by SDL.
So for linux people they could still write SDl_XXX("") and for win/wince/Symbian
 people we could write SDL_XXX(_T(""))

Finally if you want maximum compatibilities you could force you to always use _T() macros (or SDL_T() for instance).
So please consider my proposal, I think it would be so easy to use UNICODE aware api.
The only conversion would be to attack image lib (libjpeg, libpng, ...)
and it's not sure because wince implements also ANSI version of fopen.

Regards

vrichomme [AT] smartmobili [D.O.T] com





















#endif /* _SDL_tchar_h */
Comment 1 Sam Lantinga 2009-09-26 03:09:07 UTC
SDL 1.3 is UNICODE aware and uses UTF-8 for all API interfaces.

It also provides a handy function to convert strings to UTF-8: SDL_iconv_string()