Linux下:
linux下并没有前面提到的两个函数,需要使用函数mbstowcs和wcstombs。
mbstowcs将多字节编码转为宽字节编码;wcstombs将宽字节编码转换为多字节编码。
这两个函数,转换过程中受到系统编码类型的影响,需要通过设置来设定转换前和转换后的编码类型。通过函数setlocale进行系统编码的设置。
以下实例是解析音频文件的ID3v1相关信息:
#include <stdio.h>
#include <stdlib.h>
#include <iconv.h>
#include <string.h>
#include <locale.h>
int gbk2utf8(char *utfStr,char *srcStr,int maxUtfStrlen);
int getFileSize(FILE *file);
void readIDv1Info(char *path);
int main()
{
char *Path = "./完美世界.mp3";
readIDv1Info(Path);
return;
}
int getFileSize(FILE *file)
{
int fileLen = -1;
fseek(file,0,SEEK_END); //point to the end of the