NeoTechni Well-Known Member Licensed User Longtime User May 23, 2011 #1 Code: Compiling code. 0.09 Generating R file. 0.00 Compiling generated Java code. Error B4A line: 24 Pattern= su.DecodeBase64( Pattern ) javac 1.6.0_24 src\omnicorp\playstationcollector\main.java:1486: cannot find symbol symbol : method NumberToString(byte[]) location: class anywheresoftware.b4a.BA _pattern = BA.NumberToString(_su.DecodeBase64(_pattern)); ^ 1 error I'm trying to decode a base64encoded string, to a string.
Code: Compiling code. 0.09 Generating R file. 0.00 Compiling generated Java code. Error B4A line: 24 Pattern= su.DecodeBase64( Pattern ) javac 1.6.0_24 src\omnicorp\playstationcollector\main.java:1486: cannot find symbol symbol : method NumberToString(byte[]) location: class anywheresoftware.b4a.BA _pattern = BA.NumberToString(_su.DecodeBase64(_pattern)); ^ 1 error I'm trying to decode a base64encoded string, to a string.
agraham Expert Licensed User Longtime User May 23, 2011 #2 I assume Pattern is a String variable. You are trying to assign a Byte array to it which is not possible.
I assume Pattern is a String variable. You are trying to assign a Byte array to it which is not possible.
NeoTechni Well-Known Member Licensed User Longtime User May 23, 2011 #3 it is. I've also tried Code: dim Bytes() As Byte , Pattern As String Pattern= Settings.GetDefault("UserID", "-1" ) Bytes= su.DecodeBase64( Pattern ) pattern= bytes Compiling code. 0.08 Generating R file. 0.00 Compiling generated Java code. Error B4A line: 25 pattern= bytes javac 1.6.0_24 src\omnicorp\playstationcollector\main.java:1491: cannot find symbol symbol : method NumberToString(byte[]) location: class anywheresoftware.b4a.BA _pattern = BA.NumberToString(_bytes); ^ 1 error Click to expand... I've tried decoding the encoded string in another program to be sure, and I do get the correct value I encoded. Last edited: May 23, 2011
it is. I've also tried Code: dim Bytes() As Byte , Pattern As String Pattern= Settings.GetDefault("UserID", "-1" ) Bytes= su.DecodeBase64( Pattern ) pattern= bytes Compiling code. 0.08 Generating R file. 0.00 Compiling generated Java code. Error B4A line: 25 pattern= bytes javac 1.6.0_24 src\omnicorp\playstationcollector\main.java:1491: cannot find symbol symbol : method NumberToString(byte[]) location: class anywheresoftware.b4a.BA _pattern = BA.NumberToString(_bytes); ^ 1 error Click to expand... I've tried decoding the encoded string in another program to be sure, and I do get the correct value I encoded.
Erel B4X founder Staff member Licensed User Longtime User May 23, 2011 #4 StringUtils.DecodeBase64 returns a byte array. You need to use BytesToString keyword to convert it to a string.
StringUtils.DecodeBase64 returns a byte array. You need to use BytesToString keyword to convert it to a string.
NeoTechni Well-Known Member Licensed User Longtime User May 23, 2011 #5 Dah, you're kidding me. You keep making it so simple. And I just got it working with the ByteConverter library
Dah, you're kidding me. You keep making it so simple. And I just got it working with the ByteConverter library
D Dario126 Member Licensed User Longtime User Jun 19, 2014 #6 I get this error java.lang.StringIndexOutOfBoundsException: length=22; regionStart=0; regionLength=32 Click to expand... when running following code Code: Dim SU As StringUtils = "gaCpU6ikVpymnKOro6hkmpybq6qipw==" Dim sData1 As String Dim bData() As Byte bData = SU.DecodeBase64(sData) sData1 = BytesToString(bData, 0, sData.Length, "UTF-8") Log("DecodedData: " & sData1) Error is in BytesToString line.. Why? Is CharSet wrong? SU source string is coded by PHP base64_encode function. Last edited: Jun 19, 2014
I get this error java.lang.StringIndexOutOfBoundsException: length=22; regionStart=0; regionLength=32 Click to expand... when running following code Code: Dim SU As StringUtils = "gaCpU6ikVpymnKOro6hkmpybq6qipw==" Dim sData1 As String Dim bData() As Byte bData = SU.DecodeBase64(sData) sData1 = BytesToString(bData, 0, sData.Length, "UTF-8") Log("DecodedData: " & sData1) Error is in BytesToString line.. Why? Is CharSet wrong? SU source string is coded by PHP base64_encode function.
Erel B4X founder Staff member Licensed User Longtime User Jun 20, 2014 #7 You should have started a new thread for this question. I don't get any error (though it is not a valid UTF8 string): Code: Dim su As StringUtils Dim b() As Byte = su.DecodeBase64("gaCpU6ikVpymnKOro6hkmpybq6qipw==") Log(BytesToString(b, 0, b.Length, "UTF8"))
You should have started a new thread for this question. I don't get any error (though it is not a valid UTF8 string): Code: Dim su As StringUtils Dim b() As Byte = su.DecodeBase64("gaCpU6ikVpymnKOro6hkmpybq6qipw==") Log(BytesToString(b, 0, b.Length, "UTF8"))
D Dario126 Member Licensed User Longtime User Jun 20, 2014 #8 I had error by using "sData.Length" which was string, not byte array .. And now works with "UTF8" and "UTF-8" also. Btw. "UTF-8" is referenced as example in popup help in code editor. But I have some differences when decoded this with B4A or with PHP. But I'll move this topic to new thread .. Tnx ..
I had error by using "sData.Length" which was string, not byte array .. And now works with "UTF8" and "UTF-8" also. Btw. "UTF-8" is referenced as example in popup help in code editor. But I have some differences when decoded this with B4A or with PHP. But I'll move this topic to new thread .. Tnx ..