Wide characters support in D
Ruslan Nikolaev
nruslan_devel at yahoo.com
Mon Jun 7 21:14:17 PDT 2010
Yes, to clarify what I suggest, I can put it as follows (2 possibilities):
1. Have a special standardized type "tchar" and "tstring". Then, system libraries as well as users can use this type unless they want to do something special. There can be a compiler switch to change tchar width (essentially, to assign tchar to char, wchar or dchar), so that for each platform it can be used accordingly. In addition, tmain(tstring[] args) can be used as entry point; _topen, _treaddir, _tfopen, etc. can be added to binding.
Adv: doesn't break existent code.
Disadv: tchar and tstring may look weird for users.
2. Rename current char to bchar or schar, or something similar. Then 'char' can be used as type described above.
Adv: users are likely to use this type
Disadv: may break existent code; especially in part of bindings
I think to have something (at least (1)) would be nice feature and addition to D. Although, I do admit that there can be different opinions about it. However, TCHAR in Windows DOES work fine. In the case described above it's even better since we always work with Unicode (UTF8/16/32) unlike Windows (which use ANSI for 1 byte char), thus everything should be more or less transparent. It would be cool to hear something from D, phobos and tango developers.
P.S. For commonly used characters (e.g. '\n') the size of char will never make any difference. The problems should not occur in good code, or should occur really rare (which can be adjusted by programmer).
Thanks,
Ruslan Nikolaev
More information about the Digitalmars-d
mailing list