Talk:Enabling C++ Applications for Unicode

From RAD Studio
Jump to: navigation, search

Hello,

The sentence "By default the C++ RTL maps _tcahr to wchar_t." is incorrect. By default the C++ RTL maps _tchar [note typo in sentence] to char. You must define _UNICODE for the RTL to default to wchar_t.

The sentence "The Windows API is now wide by default." is also incorrect.

Do both of these sentence refer to the case when TCHAR_mapping is set to wchar_t? If yes, then they are correct. However, by default both the C++ RTL and the Windows API are narrow.


Suggestions for this page:

1. The issues that are specific to C++ applications are due to the fact that the C++ RTL and the Windows API are narrow by default while VCL is now Wide. Setting TCHAR_mapping to wchar_t, however, does not change the C++ RTL to wide. It only does so if one uses the floating version of the API. IOW, if there's code that calls strcpy(...). Setting TCHAR_mapping to wchar_t will *NOT* help that code. strcpy will always be narrow. Code that uses the C++ RTL must use the floating version of strcpy, that is _tcscpy(...). We have a table to the list of *floating/portable* C RTL API. We should link to that table from here.

2. We should list some strategies on how to bridge the C RTL <-> Windows API <-> VCL communication. Using the Wide versions fo the Windows and C RTL is but one solution. Sometimes that's not possible because (a) there's a third-party library involved, (b) there's significant amount of code already written, etc etc. For these cases there are other approaches such as keeping narrow chars but using utf8 encoding.

Work in Progress

RAD-1491