Hi Erel and good people,
I am trying to use erel's code to convert text to punycode and vice verse , using the internal lib IDN,
but it fails if I add a number to the string.
for example,
using the converter on https://www.punycoder.com/ ,
entering text : מסמך2
will print out : xn--2-kiclao
but b4a crashes when it get that string.
how can it be fixed ?
? ? ? ?
here's the log :
I am trying to use erel's code to convert text to punycode and vice verse , using the internal lib IDN,
B4X:
Sub ToACE (s As String) As String
Dim jo As JavaObject
jo.InitializeStatic("java.net.IDN")
Return jo.RunMethod("toASCII", Array(s))
End Sub
Sub FromACE (s As String) As String
Dim jo As JavaObject
jo.InitializeStatic("java.net.IDN")
Return jo.RunMethod("toUnicode", Array(s))
End Sub
but it fails if I add a number to the string.
for example,
using the converter on https://www.punycoder.com/ ,
entering text : מסמך2
will print out : xn--2-kiclao
but b4a crashes when it get that string.
how can it be fixed ?
? ? ? ?
here's the log :
B4X:
Logger connected to: samsung SM-J710F
--------- beginning of main
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
user id : LX13E124H6
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Url Exists.
Internet Connection OK!
Error occurred on line: 615 (Main)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at teletag.b4a.main._toace(main.java:1654)
at teletag.b4a.main._createidn(main.java:1349)
at teletag.b4a.main._goteletag(main.java:1507)
at teletag.b4a.main._btngo_click(main.java:1443)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6935)
at android.widget.TextView.performClick(TextView.java:12752)
at android.view.View$PerformClick.run(View.java:26211)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.IllegalArgumentException: Invalid input to toASCII: מסמך1
at java.net.IDN.toASCII(IDN.java:112)
at java.net.IDN.toASCII(IDN.java:134)
... 25 more
Caused by: The input does not conform to the rules for BiDi code points.. line: 0. preContext: . postContext: ך1
at android.icu.text.StringPrep.prepare(StringPrep.java:556)
at android.icu.impl.IDNA2003.convertToASCII(IDNA2003.java:180)
at android.icu.impl.IDNA2003.convertIDNToASCII(IDNA2003.java:277)
at android.icu.text.IDNA.convertIDNToASCII(IDNA.java:654)
at java.net.IDN.toASCII(IDN.java:110)
... 26 more
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
user id : LX13E124H6
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Url Exists.
Internet Connection OK!
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
user id : LX13E124H6
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
Url Exists.
Internet Connection OK!
Error occurred on line: 678 (Main)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at teletag.b4a.main._toace(main.java:1654)
at teletag.b4a.main._createidn(main.java:1349)
at teletag.b4a.main._goteletag(main.java:1507)
at teletag.b4a.main._btngo_click(main.java:1443)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6935)
at android.widget.TextView.performClick(TextView.java:12752)
at android.view.View$PerformClick.run(View.java:26211)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.IllegalArgumentException: Invalid input to toASCII: מסמך2
at java.net.IDN.toASCII(IDN.java:112)
at java.net.IDN.toASCII(IDN.java:134)
... 25 more
Caused by: The input does not conform to the rules for BiDi code points.. line: 0. preContext: . postContext: ך2
at android.icu.text.StringPrep.prepare(StringPrep.java:556)
at android.icu.impl.IDNA2003.convertToASCII(IDNA2003.java:180)
at android.icu.impl.IDNA2003.convertIDNToASCII(IDNA2003.java:277)
at android.icu.text.IDNA.convertIDNToASCII(IDNA.java:654)
at java.net.IDN.toASCII(IDN.java:110)
... 26 more
Last edited: