Logo

Username:    Password:    Remember me     Signup

Main Menu
 Home
 IRC
 Wiki
 

Welcome

Username:

Password:


Remember me

[ Signup ]
[ Forgot password? ]


ToDo/Bugs/Requests
Total tickets: 263
Open tickets: 119
Not assigned: 123

Online
Guests: 8
Members: 0
On this page: 1
Members: 362, newest: coooolihdbril


Forums
Lightfeather 3D Engine -> Forums -> Tutorials
<< Previous thread | Next thread >>  

 Easy way to open Unicode path.

Moderators: Matthias, Electron
Author Post
kornerr
Thu Feb 18 2010, 04:27PM Quote
Registered Member #132
Joined Thu Mar 08 2007, 02:08PM
Location: Russia, Siberia, Kemerovo
posts 50
<div class='indent'>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <stdlib.h>
using namespace std;

const int STRLEN = 512;

int main() {
if (!setlocale(LC_CTYPE, ""))
throw runtime_error("Can't set the specified locale!");
// L"direcotory with a gap/file"
const wchar_t *fileName = L"unicode dir path with gaps/unicode file";
char cFileName[STRLEN];
if (wcstombs(cFileName, fileName, STRLEN) == size_t(-1))
throw runtime_error("wcstombs failed");
ifstream in(cFileName);
string s;
while (getline(in, s)) {
cout << s << endl;
}

return 0;
}
</div>
So it's simply a call to wcstombs after setlocale.

OSRPG
Open Source all the way, baby ;)
Back to top
Website

Jump:     Back to top



Random Image

Latest Forum Posts
legerdemain on 06 Sep : 03:35
@woomla: Did you manage to get your build working?[more ...]

calav3ra on 04 Sep : 15:21
You are absolutely right about both parts being wr[more ...]

Matthias on 04 Sep : 10:42
I will have time to look into this and the other t[more ...]

legerdemain on 04 Sep : 06:45
Hi again, i'm trying to track down a strange crash[more ...]

legerdemain on 03 Sep : 11:03
In CGUITextArea.cpp, lines 657-658 and 679-680, th[more ...]

Backend
Our headlines can be syndicated by using either our rss or text feeds.
news.xml - news.txt


Render time: 0.1774 second(s).