46
System / SFML2 Utf template is kinda confusing
« on: January 06, 2011, 11:09:28 pm »
Aight So I'm currently working on my engine where it is going to convert the event values into javascript values. And I were stopped at TextEntered. I wanted to convert the value given to a string in javascript but the v8::String seem to only support up to Utf-16 so I thought I could use SFML to convert it but when I reached the documentation page... it was all way too confusing.
Hoped you could help me out explaining how you use it?
V8 String Documentation: http://bespin.cz/~ondras/html/classv8_1_1String.html
You create a new instance trough the v8::String::New methods.
*EDIT*
For now I did this, but I think I loose potential data(I usually don't work with these kind of stuff):
Hoped you could help me out explaining how you use it?
V8 String Documentation: http://bespin.cz/~ondras/html/classv8_1_1String.html
You create a new instance trough the v8::String::New methods.
*EDIT*
For now I did this, but I think I loose potential data(I usually don't work with these kind of stuff):
Code: [Select]
int Script::Converters::ConvertTextEnteredSignal(const SignalBase &aSignal, v8::Handle<v8::Value> *someArguments)
{
const TextEnteredSignal &signal = static_cast<const TextEnteredSignal &>(aSignal);
// <-- Where I try to convert the char but in a bad way -->
sf::String str = signal.GetChar(); // Returns the sf::Uint32
someArguments[0] = v8::String::New(str.ToAnsiString().c_str(), str.GetSize());
// <-- And here it ends -->
v8::Handle<v8::Object> windowWrapper = localWindowTemplate->NewInstance();
windowWrapper->SetInternalField(0, v8::External::New(signal.GetWindow()));
someArguments[1] = windowWrapper;
return 2;
}