Help converting Hex UTF-8 bytes to character

Trevor DeVore lists at mangomultimedia.com
Fri Jun 1 06:42:52 EDT 2018


On Fri, Jun 1, 2018 at 2:06 AM, Mark Waddingham via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On 2018-06-01 06:21, Monte Goulding via use-livecode wrote:
>
>> On 1 Jun 2018, at 2:18 pm, Trevor DeVore via use-livecode <
>>> use-livecode at lists.runrev.com> wrote:
>>>
>>> Yes it does! `format` is my new best friend.
>>>
>>
>> Hmm… why not just throw the whole thing at format? If it has one
>> escape sequence it might have others and you can’t put one in there
>> and expect a single `\` to be literal.
>>
>
> @Trevor : Monte makes a good point here - \x is the standard C escape for
> a single byte char. If a string format does \x, then it also has to escape
> \ as \\ - unless it requires \ to be encoded in \x form (which is certainly
> plausible - URL encoding requires that of % which is the escape character).
>
> Do you have a spec for the escaped strings you are processing?
>

I tried passing the entire string in but it makes `format` barf. The data
is coming from a database field where ActiveRecord has serialized some json
encoded data. The data contains some ActiveRecord (Ruby) encoding
information. Years ago a bug somewhere in our system caused some data to be
encoded incorrectly in a few cases. I'm not sure how it happened or if
there are any rules I can count on. My search and replace solution has
worked properly thus far. Fortunatley I don't have many more records to
process.

-- 
Trevor DeVore
ScreenSteps
www.screensteps.com



More information about the use-livecode mailing list