diff options
author | Nil Admirari <nil-admirari@mailo.com> | 2022-06-20 13:29:57 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2022-06-21 13:27:46 +0300 |
commit | cc5844da988fb7ca1051775a3dac43de77bf3881 (patch) | |
tree | c1db8e8f0e789162dabd87187ec695d0e97b440f /libavdevice/reverse.c | |
parent | c11fb467312716f15247397ebafc0093d5e7cab0 (diff) | |
download | ffmpeg-cc5844da988fb7ca1051775a3dac43de77bf3881.tar.gz |
libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8(), freeenv_utf8() and getenv_dup()
wchartoutf8() converts strings returned by WinAPI into UTF-8,
which is FFmpeg's preffered encoding.
Some external dependencies, such as AviSynth, are still
not Unicode-enabled. utf8toansi() converts UTF-8 strings
into ANSI in two steps: UTF-8 -> wchar_t -> ANSI.
wchartoansi() is responsible for the second step of the conversion.
Conversion in just one step is not supported by WinAPI.
Since these character converting functions allocate the buffer
of necessary size, they also facilitate the removal of MAX_PATH limit
in places where fixed-size ANSI/WCHAR strings were used
as filename buffers.
On Windows, getenv_utf8() wraps _wgetenv() converting its input from
and its output to UTF-8. Strings returned by getenv_utf8()
must be freed by freeenv_utf8().
On all other platforms getenv_utf8() is a wrapper around getenv(),
and freeenv_utf8() is a no-op.
The value returned by plain getenv() cannot be modified;
av_strdup() is usually used when modifications are required.
However, on Windows, av_strdup() after getenv_utf8() leads to
unnecessary allocation. getenv_dup() is introduced to avoid
such an allocation. Value returned by getenv_dup() must be freed
by av_free().
Because of cleanup complexities, in places that only test the existence
of an environment variable or compare its value with a string
consisting entirely of ASCII characters, the use of plain getenv()
is still preferred. (libavutil/log.c check_color_terminal()
is an example of such a place.)
Plain getenv() is also preffered in UNIX-only code,
such as bktr.c, fbdev_common.c, oss.c in libavdevice
or af_ladspa.c in libavfilter.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavdevice/reverse.c')
0 files changed, 0 insertions, 0 deletions