Question

I need to know how to store String data in my JavaCard, any help please ? P.S : JavaCard does not support String type.

Was it helpful?

Solution 2

Java Card Three small primitive data types only (boolean, byte, short)
It has Optional support for integer (int) primitive data type.

Strings can be represented as array of characters or bytes.
However characters are not supported(As for as I know).

Hence you can represent it using array of bytes:

byte str[]; //creating array of byte
str = {'s' , 't' , 'a' , 'c' , 'k'}; // initializing array

My answer is same as above but with little more explanation.
Hope this helps.

OTHER TIPS

You can represent it as byte array:

byte[] str = {'s', 't', 'r', 'i', 'n', 'g'};

This will use the lower 8 bits of each 16 bit code point. That will work fine within the ASCII range of characters, but will not generate any particular encoding for any code point above 0x7F (127 in decimals).

Javacard is a very small subset of the Java it not support Long, double, float, and all the wrapper classes Char, String Multidimensional array Dynamic class loading. It only support Boolean, byte, short Int.

Starting from JavaCard API v 3.0.4, there is support for StringUtil class. However, it is mostly unsupported by currently (2018) freely available cards (see JCAlgTest page listing support for javacardx.framework.string v1.0)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top