Fix hue hash for emoji-heavy nicks

This commit is contained in:
Joscha 2022-07-04 22:40:49 +02:00
parent 93cc2a6c13
commit 603876738f

View file

@ -14,8 +14,8 @@ fn normalize(text: &str) -> String {
/// [0]: https://github.com/euphoria-io/heim/blob/master/client/lib/hueHash.js
fn hue_hash(text: &str, offset: i64) -> u8 {
let mut val = 0_i32;
for char in text.chars() {
let char_val = (char as i32).wrapping_mul(439) % 256;
for bibyte in text.encode_utf16() {
let char_val = (bibyte as i32).wrapping_mul(439) % 256;
val = val.wrapping_mul(33).wrapping_add(char_val);
}