encodeStringChunk method
Encodes the stringChunk
into the bits of an int.
Implementation
int encodeStringChunk(String stringChunk) {
if (stringChunk.length > chunksPerInt) {
throw ArgumentError(
'$charMap does not support encoding strings that are of size ${stringChunk.length} (MaxSize: $chunksPerInt).');
}
var retVal = 0;
for (var i = 0; i < stringChunk.length; i++) {
final value = stringChunk[i];
if (!charMap.containsKey(value)) {
throw ArgumentError(
'$charMap does not support encoding strings with $value.');
}
retVal += charMap[value]! * pow(2, i * bitsUsed).toInt();
}
return retVal;
}