[[Module:ny-IPA]]
Fragment of a discussion from User talk:Rua
Just a hunch but, did you normalise the text to NFC before returning it? This combines diacritics with the characters before them, when possible. I found that while MediaWiki does this to the page content when you save a page, Lua doesn't do it.