在不同的语言环境中格式化双精度值 [英] Format double value in different locale

查看:85
本文介绍了在不同的语言环境中格式化双精度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C ++项目中,我使用的字符串格式如下-

In my C++ project I am using string formatting as follows -

sprintf(tag, "%g", "100.88");

如果我在英语语言环境中运行它,则映射良好.我想对其进行更改以在不同的语言环境中工作.就像在德国语言环境中一样,标记应分配为100,88.

If I run it in English locale it maps fine. I would like to make changes to it to work in different locales. Like in German locale tag should get assigned as 100,88.

我该如何实现?

我正在寻找与

system.convert.tostring(100.88 , 
                        system.globalization.culturalinfo.invariantculture)

推荐答案

如果您使用的是 iostreams ,您可以通过流填充您要使用的语言环境.

If you were using iostreams, you'd do this by imbuing the stream with the locale you want to use.

这篇关于在不同的语言环境中格式化双精度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆