Skip to main content
Topic: utf8 to string? (Read 3147 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

utf8 to string?

Could any developer tell me how to convert an utf8 string (like the one "info->get_file_path()" returns), to something that a fopen() could understand?
(I know i should be using the reader class, but I don't plan to modify the whole read funcion right now)

I've been checking the sources, and the nearer thing i've found is the param_os_to_utf8 class, but I don't know how to use that. Any clues?

utf8 to string?

Reply #1
Uh oh, using fread sounds like a really bad idea...
Anyway, you get Ansi string from UTF-8 with string_ansi_from_utf8(utf8_string).

utf8 to string?

Reply #2
Tried that already, but it gives me an uninitialized string ( that is.. all "ÍÍÍÍ"... ).

utf8 to string?

Reply #3
,Jul 13 2003, 07:44 PM] Tried that already, but it gives me an uninitialized string ( that is.. all "ÍÍÍÍ"... ).

Can you post your code that gets invalid values from string_ansi_from_utf8 and exact SDK version number you are using ?

utf8 to string?

Reply #4
This is the line

const char *_f = string_ansi_from_utf8(info->get_file_path());

from inside the "virtual int open(reader * r,file_info * info,int full_open)" function.
(Edit: btw, this is an input plugin)

I've tried this with the 0.7SDK (b15). I might be doing something wrong if that should work.

I just include in my project files the file "component_client.cpp" and include the following headers in the main file:

#include <input.h>
#include <tagread.h>
#include <file_info_helper.h>
#include <console.h>
#include <config.h>

I link to foobar2000_SDK.lib alone.

utf8 to string?

Reply #5
Bad idea.
It creates temporary string_ansi_from_utf8 object, gets the string pointer from it, then immediately destroys it.
Try this:

string_ansi_from_utf8 _f(info->get_file_path());

utf8 to string?

Reply #6
Thanks. That made it work.

The component is the foo_psy, which I'll update it soon in the 3rd party components ( new tracker engine version ).

SimplePortal 1.0.0 RC1 © 2008-2019