简体   繁体   中英

Store a String data into my JavaCard

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

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).

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM