From: "Martin Storsjö" <martin@martin.st>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v20 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8(), freeenv_utf8() and getenv_dup()
Date: Mon, 20 Jun 2022 22:05:18 +0300 (EEST)
Message-ID: <d2843065-eed7-f214-7f42-13a745dd43e8@martin.st> (raw)
In-Reply-To: <20220620103001.15035-1-nil-admirari@mailo.com>
On Mon, 20 Jun 2022, Nil Admirari wrote:
> 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.
> ---
> configure | 1 +
> libavutil/getenv_utf8.h | 86 ++++++++++++++++++++++++++++++++++++++
> libavutil/wchar_filename.h | 53 +++++++++++++++++++++++
> 3 files changed, 140 insertions(+)
> create mode 100644 libavutil/getenv_utf8.h
This set looks good to me, thanks! Will push tomorrow if there's nothing
more to add on it.
// Martin
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-06-20 19:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 10:29 Nil Admirari
2022-06-20 10:29 ` [FFmpeg-devel] [PATCH v20 2/5] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW Nil Admirari
2022-06-20 10:29 ` [FFmpeg-devel] [PATCH v20 3/5] fftools: Remove MAX_PATH limit and switch to UTF-8 versions of fopen() and getenv() Nil Admirari
2022-06-20 10:30 ` [FFmpeg-devel] [PATCH v20 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv() Nil Admirari
2022-06-20 10:30 ` [FFmpeg-devel] [PATCH v20 5/5] libavfilter/vf_frei0r.c: Use " Nil Admirari
2022-06-20 19:05 ` Martin Storsjö [this message]
2022-06-21 10:33 ` [FFmpeg-devel] [PATCH v20 1/5] libavutil: Add wchartoutf8(), wchartoansi(), utf8toansi(), getenv_utf8(), freeenv_utf8() and getenv_dup() Martin Storsjö
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2843065-eed7-f214-7f42-13a745dd43e8@martin.st \
--to=martin@martin.st \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git