March 26, 2020 Contributors


ec_convert_string — Convert a string from one encoding to another


#include "misc/converter.h"

| int **ec_convert_string** ( | fromcode, |   |
|   | fromstring, |   |
|   | tocode, |   |
|   | deststring); |   |

const char * <var class="pdparam">fromcode</var>;
string * <var class="pdparam">fromstring</var>;
const char * <var class="pdparam">tocode</var>;
string * <var class="pdparam">deststring</var>;



This reference page was automatically generated from functions found in the header files in the development branch. The function described here may not exist in generally available versions of Momentum, and may change in behavior when it is generally available. Consult your vendor for definitive advice on the use of this function.

Convert a string from one encoding to another.

This is a convenience wrapper around opening a converter and converting each portion of the source string through it and storing it in the destination string.



the encoding used for the input data


the source of the input data


the encoding to be used for the output data


the destination for the converted data

Data is read from the start of the buffer in fromstring. If it is disk backed, the next chunk will be requested until no more chunks are available.

Return Values

Returns ECCONV_OK on success, or some other value on error.


This function may induce IO or otherwise block the caller. Blocking in the scheduler thread will lead to degraded performance and should be avoided at all costs. If your code is running in the IO subsystem, the core will have already taken steps to ensure that blocking is acceptable. Otherwise, you should look at using the thread pool API to run a job in the IO pool.