c++ 读取ini配置文件,文件内容包含中文

该博客主要介绍了如何处理C++中读取包含中文内容的ini配置文件,重点是将文件编码转换为UTF-16LE以便正确解析中文字符。
摘要由CSDN通过智能技术生成

读取含中文内容ini文件代码

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstring>


string outline_image_path;

LPCTSTR ini_path = "D:/cudaHygiene/image/带蓝芯弧形/带蓝芯弧形.ini";


//读取整型ini数据
int getInt(LPCTSTR lpKeyName, INT nDefault)
{
	int value = GetPrivateProfileInt("Detection", lpKeyName, nDefault, ini_path);
	return value;
}

//读取浮点型ini数据
double getDouble(LPCTSTR lpKeyName, LPCTSTR nDefault)
{
	//读取字符型ini数据
	char value[20];
	GetPrivateProfileString("Detection", lpKeyName, nDefault, value, sizeof(value), ini_path);
	//转为double型
	return strtod(value, NULL);
}


void read_ini()
{
	int model_flag = getInt("model_flag", 0);
	int filter_flag = getInt("model_flag", 0);
	int defect_distance = getInt("defect_distance", 1);
	int defect_height = getInt("defect_height", 1);
	int defect_width = getInt("defect_width", 1);
	double Zoom_f
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值