Hydrogenaudio Forums

Hosted Forums => foobar2000 => Development - (fb2k) => Topic started by: [JAZ] on 2003-07-13 17:22:52

Title: utf8 to string?
Post by: [JAZ] on 2003-07-13 17:22:52
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?
Title: utf8 to string?
Post by: Case on 2003-07-13 17:31:59
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).
Title: utf8 to string?
Post by: [JAZ] on 2003-07-13 17:44:58
Tried that already, but it gives me an uninitialized string ( that is.. all "ÍÍÍÍ"... ).
Title: utf8 to string?
Post by: Peter on 2003-07-13 18:36:47
Quote
,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 ?
Title: utf8 to string?
Post by: [JAZ] on 2003-07-13 19:11:38
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.
Title: utf8 to string?
Post by: Peter on 2003-07-13 19:19:04
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());
Title: utf8 to string?
Post by: [JAZ] on 2003-07-13 19:28:37
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