Substitute (String) bug

I was trying to change from chars to html numbers (0 => 0) with Substitute (String) (anyway: is there a faster\better way for this task?).
I found that when the node finds one of these chars
0 | 1 | 2 | 3 | 4
it outputs the wrong result.
It substitutes the char, then it substitutes again the first number of the html entity, and then keeps going on with this wrong logic until it stops (anyway it seems to loop on a single char max 3 times); as a plus it nests the results.

0, instead of 0, becomes
through something like these steps:

0 =>
0 (keeps searching: it finds 4 which is 4) =>
0 (keeps searching: it finds 5 which is 5) =>
0 (keeps searching: it finds 8 which is 8) =>
0 (at this point the iteration stops)

I hope that the nesting explained this way is clear enough.

See attached patch with few inputs to make quick tests. (4.3 kB)

without checking your patch…
have you searched the nodebrowser for “encode”, “decode”, “html”…?

Thank you.

Yes, but if I input AB into Encode (String HTML) I get AB not AB.
I read on MSDN that MS library restricts the “translation” to “special chars” as >, &, ".
That’s why I patched that.
Unless I’m missing something.

wow, really i have no idea then, what you’re up to here: “change from chars to html numbers” can you elaborate on that? my closest guess would be AsRaw (String) but that does not seem to suit your “html numbers”. any documentation-links on what you are looking for?

I’m sorry, I know I have used no proper terms to explain this issue.

I’m trying to find something like AsRaw (String Hex), which returns what I previously described.

ah, so on that page you see that those “html numbers” are simply integer representations of the characters with some &# added. so try AsRaw (String) and then AsValue (Raw) set to Byte. that should get you there.

Thank you, I should have noticed it.
And, oh, I should have had some familiarity with As… nodes.
So that will work only for ASCII char, I guess. I’ll find it.

Getting back to topic, I made some changes to the files - which are two because I was copy\pasting, errr, and it was faster and then I found this issue -, moving incriminated lines all the way down the end of file. I get errors on chars that previously worked fine.
I still think there’s an issue with Substitute (String) node.