【问题标题】:Gnuplot: Convert integer to ASCII valueGnuplot:将整数转换为 ASCII 值
【发布时间】:2016-03-01 09:01:03
【问题描述】:

我想在一个 gnuplot 脚本中生成多个图,并希望每个图的标题以大写字母开头,即第一个图的标题为 (A) sample title for first chart,第二个图的标题为 (B) sample title for second chart,并且以此类推。

在Java中,为此我基本上必须这样做

int i = 65;       // ASCII value for 65
char c = (char)i; // Convert 65 to corresponding ASCII value ('A')
i++;
// Use c; then repeat

我刚刚通过使用gprintf%c 格式化程序在gnuplot 中尝试了类似的东西,但由于这个问题我无法让它工作

这些格式说明符与标准 C 语言例程 sprintf() 使用的格式说明符不同。

长问题短:如何将整数转换为其对应的ASCII 值?

【问题讨论】:

    标签: ascii gnuplot type-conversion data-conversion


    【解决方案1】:
    gnuplot> print sprintf("%c", 65)
    #A
    

    Gnuplot 提供了一个gprintf,它使用了 gnuplot 格式说明符和 sprintf。

    【讨论】:

    • 谢谢,按预期工作!不知何故忽略了 sprintf,只找到了 gprintf。
    猜你喜欢
    • 2014-03-31
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 2014-08-15
    • 1970-01-01
    • 2013-02-08
    • 2016-08-01
    • 2017-12-23
    相关资源
    最近更新 更多