标签:roc name main hda names sda pre \n serve
mac版://
// main.m
// test
//
// Created by haidrgon on 2018/12/20.
// Copyright ? 2018 haidrgon. All rights reserved.
//
#import <Foundation/Foundation.h>
#include<iostream>
#include <string>
#include <stdlib.h>
#import<cwchar>
#import<wchar.h>
using namespace std;
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
wchar_t* temp=L"abc123你我他";
wstring wstr = temp;
wprintf(L"%s\n", wstr.c_str());
// wcout.imbue(locale("chs"));
wcout<<wstr<<endl;
NSData *data = [NSData dataWithBytes:wstr.data() length:sizeof(wchar_t) * wstr.size()];
NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF32LittleEndianStringEncoding];
NSLog(@"str %@", str);
NSLog(@"Hello, World!");
cout<<[str UTF8String]<<endl;
}
return 0;
}
linux版
#include<iostream>
#include<string>
#include<locale>
using namespace std;
int main()
{
wstring wstr=L"世界你好!";
locale loc("zh_CN.UTF-8");
locale::global(loc);
wcout<<wstr<<endl;
return 0;
}
标签:roc name main hda names sda pre \n serve
原文地址:http://blog.51cto.com/haidragon/2333629