mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
improved handling of unicode chat messages
This commit is contained in:
parent
1eb6c06ac3
commit
90c5e6c7f9
4 changed files with 13 additions and 1 deletions
BIN
data/unicode-saytext.dem
Normal file
BIN
data/unicode-saytext.dem
Normal file
Binary file not shown.
1
data/unicode-saytext.json
Normal file
1
data/unicode-saytext.json
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -183,7 +183,13 @@ impl BitRead<LittleEndian> for SayText2Message {
|
|||
|
||||
// cleanup color codes
|
||||
let mut text = text.replace(char::from(1), "").replace(char::from(3), "");
|
||||
while let Some(pos) = text.find(char::from(7)) {
|
||||
while let Some(pos) = text.chars().enumerate().find_map(|(index, c)| {
|
||||
if c == char::from(7) {
|
||||
Some(index)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}) {
|
||||
text = text
|
||||
.chars()
|
||||
.take(pos)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,11 @@ fn snapshot_test_malformed_cvar() {
|
|||
snapshot_test("data/malformed_cvar.dem", "data/malformed_cvar.json");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_test_unicode_chat() {
|
||||
snapshot_test("data/unicode-saytext.dem", "data/unicode-saytext.json");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snapshot_test_player_in_update() {
|
||||
snapshot_test("data/nousers.dem", "data/nousers.json");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue