EReg.matchedPos() and UTF-8 strings on neko and native

48 views
Skip to first unread message

Rezmason

unread,
Jun 3, 2013, 10:52:09 AM6/3/13
to haxe...@googlegroups.com
I'm writing a text display for my game; one of the things it does is style text based on a simple style tag syntax. This means I need to find, analyze and remove each tag from the text, which I do with regular expressions and such.

However, what I'm finding on the neko and native targets is that, while regular expressions often work as-is, some of the methods I'm relying on, like EReg.matchedPos(), are returning data that I can't plus into String.substr() or into haxe.Utf8.sub(). What am I supposed to do to in these situations to get working string matching? Do I need to decode the input string and the EReg string? Does anyone have experience with this stuff?

Andreas Mokros

unread,
Jun 3, 2013, 3:46:58 PM6/3/13
to haxe...@googlegroups.com
Hi.

On Mon, 3 Jun 2013 07:52:09 -0700 (PDT)
Rezmason <jeremy...@gmail.com> wrote:
> However, what I'm finding on the neko and native targets is that,
> while regular expressions often work as-is, some of the methods I'm
> relying on, like EReg.matchedPos(), are returning data that I can't
> plus into String.substr() *or* into haxe.Utf8.sub(). What am I
> supposed to do to in these situations to get working string matching?

Did you try /u flag for UTF-8 matching?

--
Mockey

Rezmason

unread,
Jun 3, 2013, 4:55:53 PM6/3/13
to haxe...@googlegroups.com
I didn't know about that. That'll probably help considerably! 

Sadly, it looks like the native targets don't support UTF8 ERegs. There seems to be an improvement when I build with the neko target, but I'm having a lot of difficulty debugging it – the process terminates without a stack trace. I'll bring this up with Granick.


On Monday, June 3, 2013 12:46:58 PM UTC-7, Andreas Mokros wrote:
Hi.

Rezmason

unread,
Jun 4, 2013, 9:10:54 PM6/4/13
to haxe...@googlegroups.com
That worked! By foregoing Stringtools, adding the 'u' flag to my ERegs and using the methods on haxe.Utf8 whenver possible, I was able to add UTF8 support to my app!

As I mentioned before, UTF-8 matching apparently isn't currently supported in the Mac target of NME, but that's a different problem.

It'd be neat if Haxe had a -utf8 flag that used UTF-8-friendly code. It'd add some overhead, but I think it would make things much easier when targeting neko and php.
Reply all
Reply to author
Forward
0 new messages