...
This commit is contained in:
@@ -8,39 +8,20 @@ pub fn unescapeString(allocator: std.mem.Allocator, raw: []const u8) ![]u8 {
|
||||
while (i < raw.len) {
|
||||
if (raw[i] == '\\' and i + 1 < raw.len) {
|
||||
i += 1;
|
||||
switch (raw[i]) {
|
||||
'n' => {
|
||||
result[j] = '\n';
|
||||
},
|
||||
't' => {
|
||||
result[j] = '\t';
|
||||
},
|
||||
'r' => {
|
||||
result[j] = '\r';
|
||||
},
|
||||
'\\' => {
|
||||
result[j] = '\\';
|
||||
},
|
||||
'"' => {
|
||||
result[j] = '"';
|
||||
},
|
||||
'0' => {
|
||||
result[j] = 0;
|
||||
},
|
||||
'`' => {
|
||||
result[j] = '`';
|
||||
},
|
||||
else => {
|
||||
result[j] = raw[i];
|
||||
},
|
||||
}
|
||||
j += 1;
|
||||
i += 1;
|
||||
result[j] = switch (raw[i]) {
|
||||
'n' => '\n',
|
||||
't' => '\t',
|
||||
'r' => '\r',
|
||||
'\\' => '\\',
|
||||
'"' => '"',
|
||||
'0' => 0,
|
||||
else => raw[i],
|
||||
};
|
||||
} else {
|
||||
result[j] = raw[i];
|
||||
j += 1;
|
||||
i += 1;
|
||||
}
|
||||
j += 1;
|
||||
i += 1;
|
||||
}
|
||||
return result[0..j];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user