是否有一个 Unicode 字符的作用类似于退格键或者是不可见的?
我弄乱了一系列随机的Unicode字符。我生成了两个不同长度相同的不同字符串。它们都在0到255之间的随机Unicode字符填充。我注意到程序后一个字符串的长度与另一个字符串的长度不同。剂量有人知道在Unicode中是否有一个看不见的角色或角色删除该字符?
//coded in javascript but the native language is Java
function generate(text) {
//create an decode key array
let decodeKey = [];
for (let i = 0; i < text.length * 2; i++) {
decodeKey.push(Math.floor(Math.random() * 10));
}
let binary = [];
for (let i = 0; i < text.length; i++) {
//turn text to binary and split at every 4th character
let b = text.charCodeAt(i).toString(2);
while (b.length < 8) {
b = "0" + b;
}
binary.push(b.slice(0, 4));
binary.push(b.slice(3));
}
//convert binary to a number and multiply by the decode key
let nums = [];
for (let i = 0; i < binary.length; i++) {
nums.push(parseInt(binary[i].toString(10)) * decodeKey[i]);
}
//convert nums to unicode
let uniChars = [];
for (let i = 0; i < nums.length; i++) {
uniChars.push(String.fromCharCode(parseInt(nums[i])));
}
//create final string with decode key at the bottom
let result = "";
for (let i = 0; i < uniChars.length; i++) {
result += uniChars[i];
}
result += "\n"
for (let i = 0; i < decodeKey.length; i++) {
result += String.fromCharCode(decodeKey[i]);
}
//return the result
return result;
}
console.log(generate("Test / Sample Text, Test / Sample Text, Test / Sample Text, Test / Sample Text"));
I was messing around with strings of random Unicode characters. I generated two different string that both had the same length. They were both populated with random Unicode characters between 0 and 255. I noticed after I ran the program the length of one string was different than the other. Dose anyone know if there is an invisible character or character that deletes there character before it in Unicode?
//coded in javascript but the native language is Java
function generate(text) {
//create an decode key array
let decodeKey = [];
for (let i = 0; i < text.length * 2; i++) {
decodeKey.push(Math.floor(Math.random() * 10));
}
let binary = [];
for (let i = 0; i < text.length; i++) {
//turn text to binary and split at every 4th character
let b = text.charCodeAt(i).toString(2);
while (b.length < 8) {
b = "0" + b;
}
binary.push(b.slice(0, 4));
binary.push(b.slice(3));
}
//convert binary to a number and multiply by the decode key
let nums = [];
for (let i = 0; i < binary.length; i++) {
nums.push(parseInt(binary[i].toString(10)) * decodeKey[i]);
}
//convert nums to unicode
let uniChars = [];
for (let i = 0; i < nums.length; i++) {
uniChars.push(String.fromCharCode(parseInt(nums[i])));
}
//create final string with decode key at the bottom
let result = "";
for (let i = 0; i < uniChars.length; i++) {
result += uniChars[i];
}
result += "\n"
for (let i = 0; i < decodeKey.length; i++) {
result += String.fromCharCode(decodeKey[i]);
}
//return the result
return result;
}
console.log(generate("Test / Sample Text, Test / Sample Text, Test / Sample Text, Test / Sample Text"));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论