userNameToAscii function
将 abc123之类的用户名转为ascii码
Implementation
List<int> userNameToAscii(String username) {
if (username.length > 10) {
print('用户名长度不能超过10,请检查');
return [];
}
String text = username;
List<int> asciiList = [];
for (int i = 0; i < text.length; i++) {
int asciiCode = text.codeUnitAt(i);
asciiList = [...asciiList, asciiCode];
// print('Character: ${text[i]}, ASCII Code: $asciiCode');
}
// username.codeUnits
return asciiList;
}