Search code examples
cstringcharacter-encodingdynamic-c

Convert integer to character and vice versa


How to convert integer to char and vice versa in "Dynamic C".

Use VB.NET as bellow:

Dim i As Integer
Dim c As Char

' Integer to Character
i = 302
c = ChrW(302)
Debug.Print(c)  'Result: Į

' Character to Integer
Dim j As Integer
j = AscW(c)
Debug.Print(CStr(j))  ' Result: 302

Thanks


Solution

  • Why dont you use an other type like uint16_t that can be used for UCS2 ? I mean char is used for ascii and extended 0-255 ~ uint8_t, if you need more dont use char.

    uint16_t c=302;