本文整理汇总了C++中std::u16string::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ u16string::c_str方法的具体用法?C++ u16string::c_str怎么用?C++ u16string::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::u16string
的用法示例。
在下文中一共展示了u16string::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyArabicShaping
// Takes UTF16 input in logical order and applies Arabic shaping to the input while maintaining
// logical order. Output won't be intelligible until the bidirectional algorithm is applied
std::u16string applyArabicShaping(const std::u16string& input) {
UErrorCode errorCode = U_ZERO_ERROR;
const int32_t outputLength =
u_shapeArabic(mbgl::utf16char_cast<const UChar*>(input.c_str()), static_cast<int32_t>(input.size()), nullptr, 0,
(U_SHAPE_LETTERS_SHAPE & U_SHAPE_LETTERS_MASK) |
(U_SHAPE_TEXT_DIRECTION_LOGICAL & U_SHAPE_TEXT_DIRECTION_MASK),
&errorCode);
// Pre-flighting will always set U_BUFFER_OVERFLOW_ERROR
errorCode = U_ZERO_ERROR;
std::u16string outputText(outputLength, 0);
u_shapeArabic(mbgl::utf16char_cast<const UChar*>(input.c_str()), static_cast<int32_t>(input.size()), mbgl::utf16char_cast<UChar*>(&outputText[0]), outputLength,
(U_SHAPE_LETTERS_SHAPE & U_SHAPE_LETTERS_MASK) |
(U_SHAPE_TEXT_DIRECTION_LOGICAL & U_SHAPE_TEXT_DIRECTION_MASK),
&errorCode);
// If the algorithm fails for any reason, fall back to non-transformed text
if (U_FAILURE(errorCode))
return input;
return outputText;
}
示例2: fsMakePath
Directory::Directory(FS_Archive archive, const std::u16string& root)
{
load = false;
err = 0;
Handle handle;
list.clear();
err = FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_UTF16, root.c_str()));
if (R_FAILED(err))
{
return;
}
u32 result = 0;
do {
FS_DirectoryEntry item;
err = FSDIR_Read(handle, &result, 1, &item);
if (result == 1)
{
list.push_back(item);
}
} while(result);
err = FSDIR_Close(handle);
if (R_FAILED(err))
{
list.clear();
return;
}
load = true;
}
示例3: sizeof
std::string to_utf8(const std::u16string& str)
{
icu_handle::get();
static_assert(sizeof(char16_t) == sizeof(UChar),
"Invalid UChar definition in ICU");
// looks dangerous, but isn't: UChar is guaranteed to be a 16-bit
// integer type, so all we're doing here is going between signed vs.
// unsigned
auto buf = reinterpret_cast<const UChar*>(str.c_str());
icu::UnicodeString u16str{buf};
return icu_to_u8str(u16str);
}
示例4: Load
void KMX_Environment::Load(std::u16string const & key, std::u16string const & value) {
assert(!key.empty());
if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_PLATFORM)) {
_platform = value;
}
else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_BASELAYOUT)) {
_baseLayout = value;
}
else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_BASELAYOUTALT)) {
_baseLayoutAlt = value;
}
else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_SIMULATEALTGR)) {
_simulateAltGr = value == u"1";
}
else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_CAPSLOCK)) {
_capsLock = value == u"1";
}
else if (!u16icmp(key.c_str(), KM_KBP_KMX_ENV_BASELAYOUTGIVESCTRLRALTFORRALT)) {
_baseLayoutGivesCtrlRAltForRAlt = value == u"1";
}
else {
// Unsupported key
assert(false);
}
}
示例5: toUnsigned
bool HTMLElementImp::toUnsigned(std::u16string& value)
{
stripLeadingAndTrailingWhitespace(value);
if (value.empty())
return false;
const char16_t* s = value.c_str();
while (*s) {
if (!isDigit(*s))
return false;
++s;
}
return true;
}
示例6: runtime_error
std::vector<std::u16string> BiDi::processText(const std::u16string& input,
std::set<std::size_t> lineBreakPoints) {
UErrorCode errorCode = U_ZERO_ERROR;
ubidi_setPara(impl->bidiText, mbgl::utf16char_cast<const UChar*>(input.c_str()), static_cast<int32_t>(input.size()),
UBIDI_DEFAULT_LTR, nullptr, &errorCode);
if (U_FAILURE(errorCode)) {
throw std::runtime_error(std::string("BiDi::processText: ") + u_errorName(errorCode));
}
return applyLineBreaking(lineBreakPoints);
}
示例7: mapToInteger
bool mapToInteger(std::u16string& value)
{
if (stripLeadingWhitespace(value).empty())
return false;
const char16_t* input = value.c_str();
const char16_t* end = input + value.length();
int u;
end = parseInt(input, end, u);
if (!end)
return false;
value.erase(end - input);
return true;
}
示例8: mapToPixelLength
bool mapToPixelLength(std::u16string& value)
{
if (stripLeadingWhitespace(value).empty())
return false;
const char16_t* input = value.c_str();
const char16_t* end = input + value.length();
int u;
end = parseInt(input, end, u);
if (!end || u < 0)
return false;
if (0 < u)
value.replace(end - input, std::u16string::npos, u"px");
else
value.erase(end - input);
return true;
}
示例9: if
void Text::findBreaksUtf16( const std::u16string &line, std::vector<size_t> *must, std::vector<size_t> *allow )
{
std::vector<uint8_t> resultBreaks;
calcLinebreaksUtf16( (uint16_t*)line.c_str(), &resultBreaks );
//
must->clear();
allow->clear();
//
for( size_t i = 0; i < resultBreaks.size(); ++i ) {
if( resultBreaks[i] == ci::UNICODE_ALLOW_BREAK )
allow->push_back( i );
else if( resultBreaks[i] == ci::UNICODE_MUST_BREAK ) {
must->push_back( i );
allow->push_back( i );
}
}
}
示例10: toPxOrPercentage
bool HTMLElementImp::toPxOrPercentage(std::u16string& value)
{
stripLeadingAndTrailingWhitespace(value);
if (value.empty())
return false;
const char16_t* s = value.c_str();
while (*s) {
if (*s == '%')
break;
if (!isDigit(*s))
return false;
++s;
}
if (!*s) {
value += u"px";
return true;
}
assert(*s == '%');
if (!s[1] && 1 < value.length())
return true;
return false;
}
示例11: handleUIEvent
void ItemTerminal::handleUIEvent(uint32 action,int32 element,std::u16string inputStr,UIWindow* window, std::shared_ptr<WindowAsyncContainerCommand> AsyncContainer)
{
cbt_->handleUIEvent(action, element, inputStr.c_str(), window, AsyncContainer);
}
示例12: run
bool PlayerTaskWin::run()
{
if (!isIdle())
{
CCLOG("PlayerTaskWin::run() - task is not idle");
return false;
}
//BOOL WINAPI CreateProcess(
// _In_opt_ LPCTSTR lpApplicationName,
// _Inout_opt_ LPTSTR lpCommandLine,
// _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
// _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
// _In_ BOOL bInheritHandles,
// _In_ DWORD dwCreationFlags,
// _In_opt_ LPVOID lpEnvironment,
// _In_opt_ LPCTSTR lpCurrentDirectory,
// _In_ LPSTARTUPINFO lpStartupInfo,
// _Out_ LPPROCESS_INFORMATION lpProcessInformation
//);
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx
SECURITY_ATTRIBUTES sa = {0};
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
// Create a pipe for the child process's STDOUT.
if (!CreatePipe(&_childStdOutRead, &_childStdOutWrite, &sa, 0) || !SetHandleInformation(_childStdOutRead, HANDLE_FLAG_INHERIT, 0))
{
CCLOG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str());
cleanup();
return false;
}
// Create a pipe for the child process's STDIN.
if (!CreatePipe(&_childStdInRead, &_childStdInWrite, &sa, 0) || !SetHandleInformation(_childStdInWrite, HANDLE_FLAG_INHERIT, 0))
{
CCLOG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str());
cleanup();
return false;
}
ZeroMemory(&_pi, sizeof(_pi));
STARTUPINFO si = {0};
si.cb = sizeof(STARTUPINFO);
si.hStdError = _childStdOutWrite;
si.hStdOutput = _childStdOutWrite;
si.hStdInput = _childStdInRead;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
#define MAX_COMMAND 4096 //MAX_PATH
const std::u16string u16command = makeCommandLine();
WCHAR command[MAX_COMMAND];
wcscpy_s(command, MAX_COMMAND, (WCHAR*)u16command.c_str());
BOOL success = CreateProcess(NULL,
command, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
0, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&si, // STARTUPINFO pointer
&_pi); // receives PROCESS_INFORMATION
if (!success)
{
CCLOG("PlayerTaskWin::run() - create process failed, for execute %s", _executePath.c_str());
cleanup();
return false;
}
_outputBuff = new CHAR[BUFF_SIZE + 1];
_outputBuffWide = new WCHAR[BUFF_SIZE];
_state = STATE_RUNNING;
cocos2d::Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false);
return true;
}
示例13: toInteger
bool toInteger(const std::u16string& value, int& output)
{
const char16_t* input = value.c_str();
const char16_t* end = input + value.length();
return parseInt(input, end, output); // Do not care what follows after digits.
}
示例14: binding_string
inline binding_string::binding_string(handles* hnd, size_t order, const std::string& str, ub1 cs_form) : m_str(brig::unicode::transform<char16_t>(str))
{
const size_t size((m_str.size() + 1) * sizeof(char16_t));
if (size > SHRT_MAX) throw std::runtime_error("OCI type error");
m_ind = OCIInd(size);
OCIBind* bnd(0);
hnd->check(lib::singleton().p_OCIBindByPos(hnd->stmt, &bnd, hnd->err, ub4(order), (void*)m_str.c_str(), m_ind, SQLT_STR, &m_ind, 0, 0, 0, 0, OCI_DEFAULT));
hnd->check(lib::singleton().p_OCIAttrSet(bnd, OCI_HTYPE_BIND, (void*)&cs_form, 0, OCI_ATTR_CHARSET_FORM, hnd->err));
} // binding_string::
示例15:
void ctr::news::add(std::u16string title, std::u16string message, void* image, u32 imageSize, bool jpeg) {
if(!initialized) {
ctr::err::set(initError);
return;
}
ctr::err::parse(ctr::err::SOURCE_NEWS_ADD_NOTIFICATION, (u32) NEWS_AddNotification((const u16*) title.c_str(), title.length(), (const u16*) message.c_str(), message.length(), image, imageSize, jpeg));
}