| @@ -180,7 +180,7 @@ namespace CodeHelpers | |||
| String addEscapeChars (const String& s) | |||
| { | |||
| MemoryOutputStream out; | |||
| writeEscapeChars (out, s.toUTF8().getAddress(), -1, -1, false, true, true); | |||
| writeEscapeChars (out, s.toRawUTF8(), -1, -1, false, true, true); | |||
| return out.toUTF8(); | |||
| } | |||
| @@ -418,7 +418,7 @@ private: | |||
| const String s (metadata [name]); | |||
| if (s.isNotEmpty()) | |||
| vorbis_comment_add_tag (&vc, vorbisName, const_cast <char*> (s.toUTF8().getAddress())); | |||
| vorbis_comment_add_tag (&vc, vorbisName, const_cast <char*> (s.toRawUTF8())); | |||
| } | |||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OggWriter) | |||
| @@ -688,7 +688,7 @@ struct AAXClasses | |||
| { | |||
| AAX_IParameter* parameter | |||
| = new AAX_CParameter<float> (IndexAsParamID (parameterIndex), | |||
| audioProcessor.getParameterName (parameterIndex).toUTF8().getAddress(), | |||
| audioProcessor.getParameterName (parameterIndex).toRawUTF8(), | |||
| audioProcessor.getParameter (parameterIndex), | |||
| AAX_CLinearTaperDelegate<float, 0>(), | |||
| AAX_CNumberDisplayDelegate<float, 3>(), | |||
| @@ -926,7 +926,7 @@ public: | |||
| JucePlugin_RTASProductId, | |||
| JucePlugin_RTASCategory); | |||
| type->DefineTypeNames (createRTASName().toUTF8().getAddress()); | |||
| type->DefineTypeNames (createRTASName().toRawUTF8()); | |||
| type->DefineSampleRateSupport (eSupports48kAnd96kAnd192k); | |||
| type->DefineStemFormats (getFormatForChans (channelConfigs [i][0] != 0 ? channelConfigs [i][0] : channelConfigs [i][1]), | |||
| @@ -33,7 +33,7 @@ | |||
| #if JUCE_MAC | |||
| static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) | |||
| { | |||
| return FSPathMakeRef (reinterpret_cast <const UInt8*> (path.toUTF8().getAddress()), destFSRef, 0) == noErr; | |||
| return FSPathMakeRef (reinterpret_cast <const UInt8*> (path.toRawUTF8()), destFSRef, 0) == noErr; | |||
| } | |||
| #endif | |||
| @@ -493,7 +493,7 @@ public: | |||
| if (file.hasFileExtension (".vst")) | |||
| { | |||
| const char* const utf8 = file.getFullPathName().toUTF8().getAddress(); | |||
| const char* const utf8 = file.getFullPathName().toRawUTF8(); | |||
| if (CFURLRef url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*) utf8, | |||
| strlen (utf8), file.isDirectory())) | |||
| @@ -556,7 +556,7 @@ public: | |||
| { | |||
| FSRef fn; | |||
| if (FSPathMakeRef ((UInt8*) file.getFullPathName().toUTF8().getAddress(), &fn, 0) == noErr) | |||
| if (FSPathMakeRef ((UInt8*) file.getFullPathName().toRawUTF8(), &fn, 0) == noErr) | |||
| { | |||
| resFileId = FSOpenResFile (&fn, fsRdPerm); | |||
| @@ -1245,7 +1245,7 @@ public: | |||
| if (index == getCurrentProgram()) | |||
| { | |||
| if (getNumPrograms() > 0 && newName != getCurrentProgramName()) | |||
| dispatch (effSetProgramName, 0, 0, (void*) newName.substring (0, 24).toUTF8().getAddress(), 0.0f); | |||
| dispatch (effSetProgramName, 0, 0, (void*) newName.substring (0, 24).toRawUTF8(), 0.0f); | |||
| } | |||
| else | |||
| { | |||
| @@ -1834,7 +1834,7 @@ private: | |||
| #if JUCE_MAC | |||
| return (VstIntPtr) (void*) &module->parentDirFSSpec; | |||
| #else | |||
| return (VstIntPtr) (pointer_sized_uint) module->fullParentDirectoryPathName.toUTF8().getAddress(); | |||
| return (VstIntPtr) (pointer_sized_uint) module->fullParentDirectoryPathName.toRawUTF8(); | |||
| #endif | |||
| } | |||
| @@ -300,13 +300,11 @@ inline int64 abs64 (const int64 n) noexcept | |||
| //============================================================================== | |||
| /** A predefined value for Pi, at double-precision. | |||
| @see float_Pi | |||
| */ | |||
| const double double_Pi = 3.1415926535897932384626433832795; | |||
| /** A predefined value for Pi, at sngle-precision. | |||
| /** A predefined value for Pi, at single-precision. | |||
| @see double_Pi | |||
| */ | |||
| const float float_Pi = 3.14159265358979323846f; | |||
| @@ -91,7 +91,7 @@ namespace FileHelpers | |||
| FSRef ref; | |||
| LSItemInfoRecord info; | |||
| return FSPathMakeRefWithOptions ((const UInt8*) path.toUTF8().getAddress(), kFSPathMakeRefDoNotFollowLeafSymlink, &ref, 0) == noErr | |||
| return FSPathMakeRefWithOptions ((const UInt8*) path.toRawUTF8(), kFSPathMakeRefDoNotFollowLeafSymlink, &ref, 0) == noErr | |||
| && LSCopyItemInfoForRef (&ref, kLSRequestBasicFlagsOnly, &info) == noErr | |||
| && (info.flags & kLSItemInfoIsInvisible) != 0; | |||
| #endif | |||
| @@ -38,7 +38,7 @@ void Logger::outputDebugString (const String& text) | |||
| { | |||
| // Would prefer to use std::cerr here, but avoiding it for | |||
| // the moment, due to clang JIT linkage problems. | |||
| fputs (text.toUTF8().getAddress(), stderr); | |||
| fputs (text.toRawUTF8(), stderr); | |||
| fputs ("\n", stderr); | |||
| fflush (stderr); | |||
| } | |||
| @@ -880,7 +880,7 @@ void Thread::setCurrentThreadName (const String& name) | |||
| [[NSThread currentThread] setName: juceStringToNS (name)]; | |||
| } | |||
| #elif JUCE_LINUX | |||
| prctl (PR_SET_NAME, name.toUTF8().getAddress(), 0, 0, 0); | |||
| prctl (PR_SET_NAME, name.toRawUTF8(), 0, 0, 0); | |||
| #endif | |||
| } | |||
| @@ -408,15 +408,15 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, | |||
| return false; | |||
| MapiMessage message = { 0 }; | |||
| message.lpszSubject = (LPSTR) emailSubject.toUTF8().getAddress(); | |||
| message.lpszNoteText = (LPSTR) bodyText.toUTF8().getAddress(); | |||
| message.lpszSubject = (LPSTR) emailSubject.toRawUTF8(); | |||
| message.lpszNoteText = (LPSTR) bodyText.toRawUTF8(); | |||
| MapiRecipDesc recip = { 0 }; | |||
| recip.ulRecipClass = MAPI_TO; | |||
| String targetEmailAddress_ (targetEmailAddress); | |||
| if (targetEmailAddress_.isEmpty()) | |||
| targetEmailAddress_ = " "; // (Windows Mail can't deal with a blank address) | |||
| recip.lpszName = (LPSTR) targetEmailAddress_.toUTF8().getAddress(); | |||
| recip.lpszName = (LPSTR) targetEmailAddress_.toRawUTF8(); | |||
| message.nRecipCount = 1; | |||
| message.lpRecips = &recip; | |||
| @@ -429,7 +429,7 @@ bool Process::openEmailWithAttachments (const String& targetEmailAddress, | |||
| for (int i = 0; i < filesToAttach.size(); ++i) | |||
| { | |||
| files[i].nPosition = (ULONG) -1; | |||
| files[i].lpszPathName = (LPSTR) filesToAttach[i].toUTF8().getAddress(); | |||
| files[i].lpszPathName = (LPSTR) filesToAttach[i].toRawUTF8(); | |||
| } | |||
| return mapiSendMail (0, 0, &message, MAPI_DIALOG | MAPI_LOGON_UI, 0) == SUCCESS_SUCCESS; | |||
| @@ -415,7 +415,7 @@ String URL::removeEscapeChars (const String& s) | |||
| // We need to operate on the string as raw UTF8 chars, and then recombine them into unicode | |||
| // after all the replacements have been made, so that multi-byte chars are handled. | |||
| Array<char> utf8 (result.toUTF8().getAddress(), (int) result.getNumBytesAsUTF8()); | |||
| Array<char> utf8 (result.toRawUTF8(), (int) result.getNumBytesAsUTF8()); | |||
| for (int i = 0; i < utf8.size(); ++i) | |||
| { | |||
| @@ -440,7 +440,7 @@ String URL::addEscapeChars (const String& s, const bool isParameter) | |||
| const CharPointer_UTF8 legalChars (isParameter ? "_-.*!'()" | |||
| : ",$_-.*!'()"); | |||
| Array<char> utf8 (s.toUTF8().getAddress(), (int) s.getNumBytesAsUTF8()); | |||
| Array<char> utf8 (s.toRawUTF8(), (int) s.getNumBytesAsUTF8()); | |||
| for (int i = 0; i < utf8.size(); ++i) | |||
| { | |||
| @@ -346,6 +346,8 @@ String::String (const CharPointer_UTF8& start, const CharPointer_UTF8& end) : | |||
| String::String (const CharPointer_UTF16& start, const CharPointer_UTF16& end) : text (StringHolder::createFromCharPointer (start, end)) {} | |||
| String::String (const CharPointer_UTF32& start, const CharPointer_UTF32& end) : text (StringHolder::createFromCharPointer (start, end)) {} | |||
| String::String (const std::string& s) : text (StringHolder::createFromFixedLength (s.data(), s.size())) {} | |||
| String String::charToString (const juce_wchar character) | |||
| { | |||
| String result (PreallocationBytes (CharPointerType::getBytesRequiredFor (character))); | |||
| @@ -2011,11 +2013,21 @@ CharPointer_UTF8 String::toUTF8() const { return StringEncodingConverter <Char | |||
| CharPointer_UTF16 String::toUTF16() const { return StringEncodingConverter <CharPointerType, CharPointer_UTF16>::convert (*this); } | |||
| CharPointer_UTF32 String::toUTF32() const { return StringEncodingConverter <CharPointerType, CharPointer_UTF32>::convert (*this); } | |||
| const char* String::toRawUTF8() const | |||
| { | |||
| return toUTF8().getAddress(); | |||
| } | |||
| const wchar_t* String::toWideCharPointer() const | |||
| { | |||
| return StringEncodingConverter <CharPointerType, CharPointer_wchar_t>::convert (*this).getAddress(); | |||
| } | |||
| std::string String::toStdString() const | |||
| { | |||
| return std::string (toRawUTF8()); | |||
| } | |||
| //============================================================================== | |||
| template <class CharPointerType_Src, class CharPointerType_Dest> | |||
| struct StringCopier | |||
| @@ -2251,6 +2263,7 @@ public: | |||
| expect (s3.indexOf (L"HIJK") == -1); | |||
| expect (s3.indexOfIgnoreCase ("hij") == 7); | |||
| expect (s3.indexOfIgnoreCase (L"hijk") == -1); | |||
| expect (s3.toStdString() == s3.toRawUTF8()); | |||
| String s4 (s3); | |||
| s4.append (String ("xyz123"), 3); | |||
| @@ -152,6 +152,9 @@ public: | |||
| /** Creates a string from an ASCII character string */ | |||
| String (const CharPointer_ASCII& text); | |||
| /** Creates a string from a UTF-8 encoded std::string. */ | |||
| String (const std::string&); | |||
| //============================================================================== | |||
| /** Creates a string from a single character. */ | |||
| static String charToString (juce_wchar character); | |||
| @@ -1045,10 +1048,23 @@ public: | |||
| To find out how many bytes you need to store this string as UTF-8, you can call | |||
| CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer()) | |||
| @see getCharPointer, toUTF16, toUTF32 | |||
| @see toRawUTF8, getCharPointer, toUTF16, toUTF32 | |||
| */ | |||
| CharPointer_UTF8 toUTF8() const; | |||
| /** Returns a pointer to a UTF-8 version of this string. | |||
| Because it returns a reference to the string's internal data, the pointer | |||
| that is returned must not be stored anywhere, as it can be deleted whenever the | |||
| string changes. | |||
| To find out how many bytes you need to store this string as UTF-8, you can call | |||
| CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer()) | |||
| @see getCharPointer, toUTF8, toUTF16, toUTF32 | |||
| */ | |||
| const char* toRawUTF8() const; | |||
| /** Returns a pointer to a UTF-16 version of this string. | |||
| Because it returns a reference to the string's internal data, the pointer | |||
| @@ -1086,6 +1102,9 @@ public: | |||
| */ | |||
| const wchar_t* toWideCharPointer() const; | |||
| /** */ | |||
| std::string toStdString() const; | |||
| //============================================================================== | |||
| /** Creates a String from a UTF-8 encoded buffer. | |||
| If the size is < 0, it'll keep reading until it hits a zero. | |||
| @@ -1310,7 +1329,7 @@ JUCE_API bool JUCE_CALLTYPE operator<= (const String& string1, const String& str | |||
| template <class traits> | |||
| std::basic_ostream <char, traits>& JUCE_CALLTYPE operator<< (std::basic_ostream <char, traits>& stream, const String& stringToWrite) | |||
| { | |||
| return stream << stringToWrite.toUTF8().getAddress(); | |||
| return stream << stringToWrite.toRawUTF8(); | |||
| } | |||
| /** This operator allows you to write a juce String directly to std output streams. | |||
| @@ -883,7 +883,7 @@ public: | |||
| void setTitle (const String& title) | |||
| { | |||
| XTextProperty nameProperty; | |||
| char* strings[] = { const_cast <char*> (title.toUTF8().getAddress()) }; | |||
| char* strings[] = { const_cast <char*> (title.toRawUTF8()) }; | |||
| ScopedXLock xlock; | |||
| if (XStringListToTextProperty (strings, 1, &nameProperty)) | |||
| @@ -2527,7 +2527,7 @@ private: | |||
| xchangeProperty (evt.xselectionrequest.requestor, | |||
| evt.xselectionrequest.property, | |||
| targetType, 8, | |||
| dragState.textOrFiles.toUTF8().getAddress(), | |||
| dragState.textOrFiles.toRawUTF8(), | |||
| dragState.textOrFiles.getNumBytesAsUTF8()); | |||
| } | |||