mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
decode app data as utf8 string to support emojis etc in peer and node names
This commit is contained in:
parent
e6d982c3f8
commit
d55e2b4db4
1 changed files with 8 additions and 2 deletions
|
|
@ -1645,10 +1645,16 @@
|
|||
}
|
||||
|
||||
},
|
||||
decodeBase64ToUtf8String: function(base64) {
|
||||
// support for decoding base64 as a utf8 string to support emojis and cyrillic characters etc
|
||||
return decodeURIComponent(atob(base64).split('').map(function(c) {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
}).join(''));
|
||||
},
|
||||
getPeerNameFromAppData: function(appData) {
|
||||
try {
|
||||
// app data should be peer name, and our server provides it base64 encoded
|
||||
return atob(appData);
|
||||
return this.decodeBase64ToUtf8String(appData);
|
||||
} catch(e){
|
||||
return "Anonymous Peer";
|
||||
}
|
||||
|
|
@ -1656,7 +1662,7 @@
|
|||
getNodeNameFromAppData: function(appData) {
|
||||
try {
|
||||
// app data should be node name, and our server provides it base64 encoded
|
||||
return atob(appData);
|
||||
return this.decodeBase64ToUtf8String(appData);
|
||||
} catch(e){
|
||||
return "Anonymous Node";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue