C API : Does utrans_openU register system transliterators?

14 views
Skip to first unread message

douglas mennella

unread,
Sep 29, 2025, 12:10:09 AM (yesterday) Sep 29
to icu-s...@unicode.org
I’m trying to understand how the C API works.

In the utrans_register documentation it says:
“NOTE: After this call the system owns the adoptedTrans and will close it. The user must not call utrans_close()on adoptedTrans.”


But in the utrans_openU documentation it says 

“the transliterator rules. See the C++ header rbt.h for rules syntax. If NULL then a system transliterator matching the ID is returned.”


Does this mean when passing a NULL for rules in utrans_openU that you’re not expected to explicitly close the returned transliterator?

Separately I’m a little unclear if I’m responsible for releasing resources of the “system” as a whole.

Any guidance would be appreciated.

Regards,
Doug

Sent from my iPhone

Markus Scherer

unread,
Sep 29, 2025, 12:19:46 PM (yesterday) Sep 29
to douglas mennella, icu-s...@unicode.org
On Sun, Sep 28, 2025 at 9:10 PM douglas mennella <douglas....@gmail.com> wrote:
I’m trying to understand how the C API works.

In the utrans_register documentation it says:
“NOTE: After this call the system owns the adoptedTrans and will close it. The user must not call utrans_close()on adoptedTrans.”


But in the utrans_openU() documentation it says 

“the transliterator rules. See the C++ header rbt.h for rules syntax. If NULL then a system transliterator matching the ID is returned.”

Same link as above. The link to utrans_openU docs is here.

Does this mean when passing a NULL for rules in utrans_openU that you’re not expected to explicitly close the returned transliterator?

No. utrans_openU() returns a pointer to a non-const UTransliterator. That means
- You own it and have to _close() it.
- When you pass it into functions that take non-const UTransliterator, it will be mutated/modified.

If you get “a system transliterator matching the ID” then it's a mutable clone.

Separately I’m a little unclear if I’m responsible for releasing resources of the “system” as a whole.

No.

Best regards,
markus

douglas mennella

unread,
Sep 29, 2025, 5:54:02 PM (19 hours ago) Sep 29
to Markus Scherer, icu-s...@unicode.org
Thanks very much.  I still have one more question in that case.  If I do register it can I save constructing a new one each time I need it?  If so do I use the same openU interface to get the registered transliterator?  How do I check if it’s registered?

Sent from my iPhone

On Sep 30, 2025, at 1:19 AM, Markus Scherer <marku...@gmail.com> wrote:



Markus Scherer

unread,
Sep 29, 2025, 7:53:06 PM (17 hours ago) Sep 29
to douglas mennella, icu-s...@unicode.org
On Mon, Sep 29, 2025 at 2:54 PM douglas mennella <douglas....@gmail.com> wrote:
If I do register it can I save constructing a new one each time I need it?  If so do I use the same openU interface to get the registered transliterator?  How do I check if it’s registered?

Once registered, you should be able to open one via its ID, without the rules. You should get a clone of what you registered, rather than getting the rules parsed again.
If something doesn't work, then you should get a failure UErrorCode.

markus

douglas mennella

unread,
Sep 29, 2025, 9:35:11 PM (16 hours ago) Sep 29
to Markus Scherer, icu-s...@unicode.org
Thanks though I’m still slightly confused.  For my case I’m not using any rules so I’m using openU with a null pointer for the rules.

The first time I call openU I and get the transliterator.  Then I register it.  The second time do I get it with openU again?  Should I expect to get a clone of the registered version?  How do I know I don’t need to follow up the second call to openU with a registration?  Can I check if the version I get back is registered?

Thanks again for your help here.

Sent from my iPhone

On Sep 30, 2025, at 8:53 AM, Markus Scherer <marku...@gmail.com> wrote:



Markus Scherer

unread,
11:29 AM (2 hours ago) 11:29 AM
to douglas mennella, icu-s...@unicode.org
On Mon, Sep 29, 2025 at 6:35 PM douglas mennella <douglas....@gmail.com> wrote:
Thanks though I’m still slightly confused.  For my case I’m not using any rules so I’m using openU with a null pointer for the rules.

The first time I call openU I and get the transliterator.  Then I register it.

Why are you registering a transliterator if you are not creating a new one from rules or providing one with custom code?
Do you have a complex compound ID that takes a long time to parse and build?
Reply all
Reply to author
Forward
0 new messages