Help us understand the problem. What is going on with this article?

Unity IL2CPP Il2CppCodeGenString から文字列を出力する

More than 1 year has passed since last update.

結構、後ろ向きなテクニックでアレです。

動作確認環境

  • Xcode 8.3.3
  • Unity 2017.1.0f3

多分、Unity 5.5.x 以上なら動きます。

方法

文字列リテラルは、大抵の場合は __stringLiteralxxxx_ の様な変数名に格納されている。
型は Il2CppCodeGenString のポインタで定義されており、API として文字列長と最初のキャラクターのアドレスを取得する手段が設けられているので、最初のアドレスから文字数分イテレートを回してあげれば OK。
尚、下記サンプルはマルチバイトは考慮していません。

Il2CppChar* c = _stringLiteralxxxx->get_address_of_m_firstChar_1();
for (int i = 0; i < _stringLiteralxxxx->___m_stringLength_0; i++) {
    printf("%c", *(c+i));
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした