New Strings


#1

Is it possible to bring the toCString() method ?

also i used to do toUTF8() on Strings to cast them to standard old C style strings “char”, but now toUTF8() does not work.
Also i can’t find a way to do String:formatted(), i always get an error about the first parameter.

String::formatted (T("%2d"), time.getMilliseconds())
1>c:\devel\ctrlr\beta\source\application\ctrlrlog.h(42) : error C2664: 'juce::String::formatted' : cannot convert parameter 1 from 'const wchar_t [4]' to 'const juce::juce_wchar *'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

String::formatted ("%2d", time.getMilliseconds())
1>c:\devel\ctrlr\beta\source\application\ctrlrlog.h(42) : error C2664: 'juce::String::formatted' : cannot convert parameter 1 from 'const char [4]' to 'const juce::juce_wchar *'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

String::formatted (String(T("%2d")).toUTF8(), time.getMilliseconds()) // a bit hardcore i know, but i was desperate
1>c:\devel\ctrlr\beta\source\application\ctrlrlog.h(42) : error C2664: 'juce::String::formatted' : cannot convert parameter 1 from 'const juce::CharPointer_UTF8' to 'const juce::juce_wchar *'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

String::formatted (String(T("%2d")), time.getMilliseconds())
1>c:\devel\ctrlr\beta\source\application\ctrlrlog.h(42) : error C2664: 'juce::String::formatted' : cannot convert parameter 1 from 'juce::String' to 'const juce::juce_wchar *'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

#2

+1


#3

If the context in which you’re using it means that an implicit cast to const char* won’t happen, then you can just call toUTF8().getAddress() and that’ll achieve the same effect. (The toCString method was misleading because what it produced was actually utf8)

For the String::formatted thing, I think what I’ll do is just to make that method take a string instead of a juce_wchar*, so that you can just pass any old type of thing in there.


#4

allright i used the toUTF8().getAddress()
and for now i removed the String::formatted stuff and used the String constructor with the precision parameter


#5

Thanks! I’ve been making some pretty fundamental changes to the String class, so please be patient as I finish ironing-out the last few glitches!


#6

don’t thank me, thank you, i’ll wait as long as it takes.