# String to std::string and char const\*?

**URL:** <https://forum.juce.com/t/string-to-std-string-and-char-const/10743>\
**Category:** General JUCE discussion\
**Created:** [July 8, 2013, 3:28pm UTC](https://forum.juce.com/t/string-to-std-string-and-char-const/10743 "2013-07-08T15:28:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [July 8, 2013, 3:28pm UTC](https://forum.juce.com/t/string-to-std-string-and-char-const/10743/1 "2013-07-08T15:28:35Z")

</div>

I’m introducing the usage of String objects in a code base that deals primarily in std::string and char const\*. What is the most correct way to pass a String object where either of these types are expected? Currently I am using String::toRawUtf8().

Should I write a free conversion function template to abstract this or something? Jules work your magic!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 8, 2013, 3:32pm UTC](https://forum.juce.com/t/string-to-std-string-and-char-const/10743/2 "2013-07-08T15:32:11Z")

</div>

Well, that sounds like String::toStdString and String::toRawUTF8 to me!
