Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Character encoding problem with a One-Click API

1574857910
Alain H.
Pro
Sheet Author
API Scripter
Hello, I have a character encoding problem that I can't solve. When I use the custom API script, it works perfectly. When it is in One-Click API, there is a display problem. Do you know how to solve the problem? Thank you in advance.
1574865271

Edited 1574865312
Ada L.
Marketplace Creator
Sheet Author
API Scripter
I ran into this problem with unicode icons I was using in the menus for some of my scripts. The solution I used to get it working was to escape the problematic characters as HTML entities.  For example ⩤ would be converted to ⩤ So that I wouldn't have to keep track of this by hand, I set up my scripts' development environments with Node/Grunt utilities to automatically convert these characters from my source code. Here's a snippet of my Grunt configurations used to do that. 'string-replace': { dist: { files: { '<%= pkg.version %>/<%= pkg.script %>': '<%= pkg.version %>/<%= pkg.script %>' } }, options: { replacements: [ { pattern: 'SCRIPT_VERSION', replacement: '<%= pkg.version %>' }, // Convert unicode characters to HTML entities. { pattern: /[\u{00FF}-\u{FFFFF}]/gu, replacement: function(match) { if (match.length === 2) { let highSurrogate = match.charCodeAt(0); let lowSurrogate = match.charCodeAt(1); let astralCodePoint = (highSurrogate - 0xD800) * 0x400 + lowSurrogate - 0xDC00 + 0x10000; return '&#' + astralCodePoint + ';'; } else if (match.length === 1) { let charCode = match.charCodeAt(0); return '&#' + charCode + ';'; } } } ] } }