A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/ucnv__cb_8h.html below:

ICU 77.1: common/unicode/ucnv_cb.h File Reference

C API: UConverter functions to aid the writers of callbacks.

Callback API for UConverter

These functions are provided here for the convenience of the callback writer. If you are just looking for callback functions to use, please see ucnv_err.h. DO NOT call these functions directly when you are working with converters, unless your code has been called as a callback via ucnv_setFromUCallback or ucnv_setToUCallback !!

A note about error codes and overflow. Unlike other ICU functions, these functions do not expect the error status to be U_ZERO_ERROR. Callbacks must be much more careful about their error codes. The error codes used here are in/out parameters, which should be passed back in the callback's error parameter.

For example, if you call ucnv_cbfromUWriteBytes to write data out to the output codepage, it may return U_BUFFER_OVERFLOW_ERROR if the data did not fit in the target. But this isn't a failing error, in fact, ucnv_cbfromUWriteBytes may be called AGAIN with the error status still U_BUFFER_OVERFLOW_ERROR to attempt to write further bytes, which will also go into the internal overflow buffers.

Concerning offsets, the 'offset' parameters here are relative to the start of SOURCE. For example, Suppose the string "ABCD" was being converted from Unicode into a codepage which doesn't have a mapping for 'B'. 'A' will be written out correctly, but The FromU Callback will be called on an unassigned character for 'B'. At this point, this is the state of the world: Target: A [..] [points after A] Source: A B [C] D [points to C - B has been consumed] 0 1 2 3 codePoint = "B" [the unassigned codepoint]

Now, suppose a callback wants to write the substitution character '?' to the target. It calls ucnv_cbFromUWriteBytes() to write the ?. It should pass ZERO as the offset, because the offset as far as the callback is concerned is relative to the SOURCE pointer [which points before 'C'.] If the callback goes into the args and consumes 'C' also, it would call FromUWriteBytes with an offset of 1 (and advance the source pointer).

Definition in file ucnv_cb.h.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4