Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution for missing std::wstring support in Android NDK?

I have a game which uses std::wstring as its basic string type in thousand of places as well as doing operations with wchar_t and its functions: wcsicmp() wcslen() vsprintf(), etc.

The problem is wstring is not supported in R5c (latest ndk at the time of this writting).

I can't change the code to use std::string because of internationalization and I would be breaking the game engine which is used by many games ...

Which options do I have?

1 - Replace string and wstring with my own string classes

This would give me better platform independency, but it is ridiculous to reimplement the wheel. I've already started with a COW implementation of strings. I need it to be COW because I use them as keys in hash_maps. This is of course lots of work and error prone ... but it seems it is something I can do.

2 - Try to fix the NDK recompiling the STLPort with my own implementations of the wide char string functions of the C standart library (wcslen, mbstowcs ... )

This would be the preferable way ... but I have no idea how to do it :(

How do I replace a function (lets say wcslen) in the libstdc++.a or libstlport_static.a? (not sure where they are :()

And as well I'm not sure which functions I need to reimplement, I know wcslen is not working so I guess they should be all ...

3 - Do you have any other idea?

I can't wait for an official fix for this and I will have to go with option #1 if I can't realize how to do #2.

I've read somewhere that if you target 2.3 you can use wstrings, but I ought to target Android 2.1.

PS: Forgot to say I need to use STL of course, but no RTTI and I can live without exceptions.

Thanks in advance!

like image 776
user548569 Avatar asked Nov 13 '22 21:11

user548569


1 Answers

Try out CrystaX's NDK. It has had stl support long before the official google one. The current version (r5), which is based off the of the official ndk r5, is still beta 3, but it does have wchar_t support.

http://www.crystax.net/android/ndk-r5.php

like image 187
Leif Andersen Avatar answered Jan 17 '23 17:01

Leif Andersen