icu-dotnet
icu-dotnet copied to clipboard
Overflow exception is thrown by Transliterate method for certain characters
We are getting an Overflow exception while passing certain characters for conversion to Translieterate method. for eg: if we pass ﷺ as input below
using (var transliteratorLatn = Icu.Transliterator.CreateInstance("Any-Latn"))
{
return transliteratorLatn.Transliterate(input);
}
If we increase the textMultiplier size to 20 instead of default 3 . i.e. if we do this
transliteratorLatn.Transliterate(input, 20);
then the it works. However we can't be always sure what that second parameter would be ? Can you please help in resolving the issue? Also would it have any performance impact in terms of memory consumption increasing the value of textMultiplier as we are upping the buffer value thats gonna hold the converted string?
Below is the exception stack trace

Worth mentioning that each occurrence of this error causes a memory leak.
ExceptionFromErrorCode.ThrowIfError(status); //exception thrown here
var result = Marshal.PtrToStringUni(textPtr, textLength);
Marshal.FreeHGlobal(textPtr); //this memory will never be freed