gpt4 book ai didi

c++ - 如何用FLTK显示Unicode?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:34:53 25 4
gpt4 key购买 nike

根据FLTK 1.3.2 documentation :

Unicode support was only recently added to FLTK and is still incomplete.

但是,据推测实现了以下内容:

It is important to note that the initial implementation of Unicode and UTF-8 in FLTK involves three important areas:

  • provision of Unicode character tables and some simple related functions
  • conversion of char* variables and function parameters from single byte per character representation to UTF-8 variable length
    sequences
  • modifications to the display font interface to accept general Unicode character or UCS code numbers instead of just ASCII or Latin1 characters.

我的问题是,如何在 FLTK 控件上实际显示 Unicode?我找不到任何接受 Unicode 的小部件功能。例如,这是 label 函数的签名:

void Fl_Widget::label (const char * text)

最佳答案

从您发布的链接:

FLTK will be entirely converted to Unicode using UTF-8 encoding. If a different encoding is required by the underlying operating system, FLTK will convert the string as needed.

您列出的三个要点是构成其实现 Unicode 支持的领域;也就是说,这些是他们正在做或计划做的事情。

  • FLTK实现者将提供Unicode字符表和一些简单的相关函数
  • FLTK 实现者将把 char* 变量和函数参数从使用 SBCS 转换为 UTF-8。 (也就是说,他们将重新实现 FLTK 函数和变量以将 char* 字符串视为 UTF-8。)
  • FLTK 实现者将修改显示字体界面,以涵盖不仅仅是 ASCII 和 Latin1 字符。

My question is, how do I actually display Unicode on my FLTK controls? I can't find any widget functions which accept Unicode. For example, this is the signature for the label function:

void Fl_Widget::label ( const char * text )

很多人错误地使用“Unicode”来表示使用 2 字节字符的编码。您链接到的 FLTK 文档不会犯这个错误。理解了这一点,文档就非常清楚地说明了如何使用具有上述签名的 Unicode:使用 UTF-8 编码将 Unicode 数据作为 char* 字符串传递。例如,如果您使用的编译器使用 UTF-8 作为执行编码:

widget.label("кошка 日本国");

或者如果您有 C++11 编译器:

widget.label( u8"кошка 日本国");

关于c++ - 如何用FLTK显示Unicode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19198848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com