Android Question The Problem When Create Lib Contains Chinese character encoding that cannot be converted.

52manhua

Member
Licensed User
This question has been raised before, but it has nothing to do with it.
However, when I want to convert a lunar calendar, I found I can't walk around this problem.
The screenshots are as follows:

b4a库编译的问题.png b4a库编译的问题2.png b4a库编译的问题3.png b4a库编译的问题4.png

Yes, It's not just for the memos , But the value ...

So, Any Help? Thx
 

52manhua

Member
Licensed User
B4X:
    private final static int[] LUNAR_INFO = {
            0x10, 0x4ae0, 0xa570, 0x54d5, 0xd260, 0xd950, 0x16554, 0x56a0, 0x9ad0, 0x55d2,
            0x4ae0, 0xa5b6, 0xa4d0, 0xd250, 0x1d255, 0xb540, 0xd6a0, 0xada2, 0x95b0, 0x14977,
            0x4970, 0xa4b0, 0xb4b5, 0x6a50, 0x6d40, 0x1ab54, 0x2b60, 0x9570, 0x52f2, 0x4970,
            0x6566, 0xd4a0, 0xea50, 0x16a95, 0x5ad0, 0x2b60, 0x186e3, 0x92e0, 0x1c8d7, 0xc950,
            0xd4a0, 0x1d8a6, 0xb550, 0x56a0, 0x1a5b4, 0x25d0, 0x92d0, 0xd2b2, 0xa950, 0xb557,
            0x6ca0, 0xb550, 0x15355, 0x4da0, 0xa5b0, 0x14573, 0x52b0, 0xa9a8, 0xe950, 0x6aa0,
            0xaea6, 0xab50, 0x4b60, 0xaae4, 0xa570, 0x5260, 0xf263, 0xd950, 0x5b57, 0x56a0,
            0x96d0, 0x4dd5, 0x4ad0, 0xa4d0, 0xd4d4, 0xd250, 0xd558, 0xb540, 0xb6a0, 0x195a6,
            0x95b0, 0x49b0, 0xa974, 0xa4b0, 0xb27a, 0x6a50, 0x6d40, 0xaf46, 0xab60, 0x9570,
            0x4af5, 0x4970, 0x64b0, 0x74a3, 0xea50, 0x6b58, 0x5ac0, 0xab60, 0x96d5, 0x92e0,
            0xc960, 0xd954, 0xd4a0, 0xda50, 0x7552, 0x56a0, 0xabb7, 0x25d0, 0x92d0, 0xcab5,
            0xa950, 0xb4a0, 0xbaa4, 0xad50, 0x55d9, 0x4ba0, 0xa5b0, 0x15176, 0x52b0, 0xa930,
            0x7954, 0x6aa0, 0xad50, 0x5b52, 0x4b60, 0xa6e6, 0xa4e0, 0xd260, 0xea65, 0xd530,
            0x5aa0, 0x76a3, 0x96d0, 0x26fb, 0x4ad0, 0xa4d0, 0x1d0b6, 0xd250, 0xd520, 0xdd45,
            0xb5a0, 0x56d0, 0x55b2, 0x49b0, 0xa577, 0xa4b0, 0xaa50, 0x1b255, 0x6d20, 0xada0,
            0x14b63, 0x9370, 0x49f8, 0x4970, 0x64b0, 0x168a6, 0xea50, 0x6aa0, 0x1a6c4, 0xaae0,
            0x92e0, 0xd2e3, 0xc960, 0xd557, 0xd4a0, 0xda50, 0x5d55, 0x56a0, 0xa6d0, 0x55d4,
            0x52d0, 0xa9b8, 0xa950, 0xb4a0, 0xb6a6, 0xad50, 0x55a0, 0xaba4, 0xa5b0, 0x52b0,
            0xb273, 0x6930, 0x7337, 0x6aa0, 0xad50, 0x14b55, 0x4b60, 0xa570, 0x54e4, 0xd160,
            0xe968, 0xd520, 0xdaa0, 0x16aa6, 0x56d0, 0x4ae0, 0xa9d4, 0xa2d0, 0xd150, 0xf252,
            0xd520
    };

    private final static String[] LUNAR_MONTH_ARRAYS = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"};
    private final static String[] LUNAR_DAY_ARRAYS = {"初", "十", "廿", "卅"};
    private final static String[] NUMBERS = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
That's test codes in Java, if this can run through, then done.
 

Erel

Administrator
Staff member
Licensed User
Use this non-UI B4J code to unicode escape the characters:
B4X:
Sub AppStart (Args() As String)
   Dim sb As StringBuilder
   sb.Initialize
   For Each s As String In Array("正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊")
       sb.Append(QUOTE).Append(UnicodeEscape(s)).Append(QUOTE).Append(",")
   Next
   Log(sb)
End Sub

Sub UnicodeEscape (s As String) As String
   Dim sb As StringBuilder
   sb.Initialize
   For i = 0 To s.Length - 1
       Dim u As String = Bit.ToHexString(Asc(s.CharAt(i)))
       sb.Append("\u")
       For i2 = 1 To 4 - u.Length
           sb.Append("0")
       Next
       sb.Append(u)
   Next
   Return sb.ToString
End Sub
Output:
"\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a",

Usage:
private final static String[] LUNAR_MONTH_ARRAYS = {"\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a"}
 

52manhua

Member
Licensed User
Use this non-UI B4J code to unicode escape the characters:
B4X:
Sub AppStart (Args() As String)
   Dim sb As StringBuilder
   sb.Initialize
   For Each s As String In Array("正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊")
       sb.Append(QUOTE).Append(UnicodeEscape(s)).Append(QUOTE).Append(",")
   Next
   Log(sb)
End Sub

Sub UnicodeEscape (s As String) As String
   Dim sb As StringBuilder
   sb.Initialize
   For i = 0 To s.Length - 1
       Dim u As String = Bit.ToHexString(Asc(s.CharAt(i)))
       sb.Append("\u")
       For i2 = 1 To 4 - u.Length
           sb.Append("0")
       Next
       sb.Append(u)
   Next
   Return sb.ToString
End Sub
Output:
"\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a",

Usage:
private final static String[] LUNAR_MONTH_ARRAYS = {"\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a"}
Thank you, Erel. This trick works~ =D
 
Top