IL2C icon indicating copy to clipboard operation
IL2C copied to clipboard

Fix string interoperability problem on using implicitly wchar_t is 16bit

Open kekyo opened this issue 2 years ago • 2 comments

The entire IL2C relies on wchar_t being 16-bit. I was completely oblivious to the fact that such an environment is possible...

  • Explanation of the content of the issue: https://stackoverflow.com/questions/35982310/c-sharp-mono-passing-stringbuilder-to-fill-with-unicode-content-in-c?rq=1
  • Test log:
    • https://github.com/kekyo/IL2C/blob/d5f3bd5accaa9791a519c0ca02f1f059c6891cdd/tests/IL2C.Core.Test.RuntimeSystems/Interoperability/Interoperability.cs#L89
    • https://github.com/kekyo/IL2C/runs/6841226615?check_suite_focus=true#step:15:51
    Failed PInvokeWcsLen("ABC") [38 ms]
    Error Message:
       Expected: 3
    But was:  2
    Stack Trace:
       at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
     at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
     at NUnit.Framework.Internal.Commands.DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)
    

Related #100

kekyo avatar Jun 11 '22 06:06 kekyo

Perhaps it would be better to introduce a type like char16_t so that it is always 16bit. However, because of the string literal problem, it cannot be said that simply defining a type and replacing it is sufficient, and it would be a bit involved in the discussion of whether to treat internally System.String as UTF8 or not.

Past related:

  • https://github.com/kekyo/IL2C/issues/23#issuecomment-433683957
  • https://github.com/kekyo/IL2C/issues/7

kekyo avatar Jun 11 '22 06:06 kekyo

Hello

NCLnclNCL avatar Aug 26 '23 18:08 NCLnclNCL