本文整理汇总了C++中AppendUTF8toUTF16函数的典型用法代码示例。如果您正苦于以下问题:C++ AppendUTF8toUTF16函数的具体用法?C++ AppendUTF8toUTF16怎么用?C++ AppendUTF8toUTF16使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AppendUTF8toUTF16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCrashID
void
GMPParent::ActorDestroy(ActorDestroyReason aWhy)
{
#ifdef MOZ_CRASHREPORTER
if (AbnormalShutdown == aWhy) {
nsString dumpID;
GetCrashID(dumpID);
nsString id;
// use the parent address to identify it
// We could use any unique-to-the-parent value
id.AppendInt(reinterpret_cast<uint64_t>(this));
id.Append(NS_LITERAL_STRING(" "));
AppendUTF8toUTF16(mDisplayName, id);
id.Append(NS_LITERAL_STRING(" "));
id.Append(dumpID);
// NotifyObservers is mainthread-only
NS_DispatchToMainThread(WrapRunnableNM(&GMPNotifyObservers, id),
NS_DISPATCH_NORMAL);
}
#endif
// warn us off trying to close again
mState = GMPStateClosing;
CloseActive();
// Normal Shutdown() will delete the process on unwind.
if (AbnormalShutdown == aWhy) {
NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, &GMPParent::DeleteProcess));
}
}
示例2: LOGD
void
GMPParent::ActorDestroy(ActorDestroyReason aWhy)
{
LOGD(("%s::%s: %p (%d)", __CLASS__, __FUNCTION__, this, (int) aWhy));
#ifdef MOZ_CRASHREPORTER
if (AbnormalShutdown == aWhy) {
nsString dumpID;
GetCrashID(dumpID);
nsString id;
// use the parent address to identify it
// We could use any unique-to-the-parent value
id.AppendInt(reinterpret_cast<uint64_t>(this));
id.Append(NS_LITERAL_STRING(" "));
AppendUTF8toUTF16(mDisplayName, id);
id.Append(NS_LITERAL_STRING(" "));
id.Append(dumpID);
// NotifyObservers is mainthread-only
NS_DispatchToMainThread(WrapRunnableNM(&GMPNotifyObservers, id),
NS_DISPATCH_NORMAL);
}
#endif
// warn us off trying to close again
mState = GMPStateClosing;
mAbnormalShutdownInProgress = true;
CloseActive(false);
// Normal Shutdown() will delete the process on unwind.
if (AbnormalShutdown == aWhy) {
mState = GMPStateClosing;
nsRefPtr<GMPParent> self(this);
// Note: final destruction will be Dispatched to ourself
mService->ReAddOnGMPThread(self);
}
}
示例3: GetURI
NS_IMETHODIMP
nsLocation::GetSearch(nsAString& aSearch)
{
if (!CallerSubsumes())
return NS_ERROR_DOM_SECURITY_ERR;
aSearch.SetLength(0);
nsCOMPtr<nsIURI> uri;
nsresult result = NS_OK;
result = GetURI(getter_AddRefs(uri));
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
if (url) {
nsAutoCString search;
result = url->GetQuery(search);
if (NS_SUCCEEDED(result) && !search.IsEmpty()) {
aSearch.Assign(PRUnichar('?'));
AppendUTF8toUTF16(search, aSearch);
}
}
return NS_OK;
}
示例4: NS_ASSERTION
nsresult
DOMFileImplFile::GetType(nsAString& aType)
{
if (mContentType.IsVoid()) {
NS_ASSERTION(mWholeFile,
"Should only use lazy ContentType when using the whole file");
nsresult rv;
nsCOMPtr<nsIMIMEService> mimeService =
do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString mimeType;
rv = mimeService->GetTypeFromFile(mFile, mimeType);
if (NS_FAILED(rv)) {
mimeType.Truncate();
}
AppendUTF8toUTF16(mimeType, mContentType);
mContentType.SetIsVoid(false);
}
aType = mContentType;
return NS_OK;
}
示例5: GetURI
void
Location::GetHost(nsAString& aHost,
nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv)
{
if (!CallerSubsumes(&aSubjectPrincipal)) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
aHost.Truncate();
nsCOMPtr<nsIURI> uri;
nsresult result;
result = GetURI(getter_AddRefs(uri), true);
if (uri) {
nsAutoCString hostport;
result = uri->GetHostPort(hostport);
if (NS_SUCCEEDED(result)) {
AppendUTF8toUTF16(hostport, aHost);
}
}
}
示例6: test_valid
bool
test_valid()
{
for (unsigned int i = 0; i < ArrayLength(ValidStrings); ++i) {
nsDependentCString str8(ValidStrings[i].m8);
nsDependentString str16(ValidStrings[i].m16);
if (!NS_ConvertUTF16toUTF8(str16).Equals(str8))
return false;
if (!NS_ConvertUTF8toUTF16(str8).Equals(str16))
return false;
nsCString tmp8("string ");
AppendUTF16toUTF8(str16, tmp8);
if (!tmp8.Equals(NS_LITERAL_CSTRING("string ") + str8))
return false;
nsString tmp16(NS_LITERAL_STRING("string "));
AppendUTF8toUTF16(str8, tmp16);
if (!tmp16.Equals(NS_LITERAL_STRING("string ") + str16))
return false;
if (CompareUTF8toUTF16(str8, str16) != 0)
return false;
}
return true;
}
示例7: GetURI
NS_IMETHODIMP
Location::GetSearch(nsAString& aSearch)
{
aSearch.SetLength(0);
nsCOMPtr<nsIURI> uri;
nsresult result = NS_OK;
result = GetURI(getter_AddRefs(uri));
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
if (url) {
nsAutoCString search;
result = url->GetQuery(search);
if (NS_SUCCEEDED(result) && !search.IsEmpty()) {
aSearch.Assign(char16_t('?'));
AppendUTF8toUTF16(search, aSearch);
}
}
return NS_OK;
}
示例8: switch
NS_IMETHODIMP
nsCSSDocumentRule::GetCssText(nsAString& aCssText)
{
aCssText.AssignLiteral("@-moz-document ");
for (URL *url = mURLs; url; url = url->next) {
switch (url->func) {
case eURL:
aCssText.AppendLiteral("url(\"");
break;
case eURLPrefix:
aCssText.AppendLiteral("url-prefix(\"");
break;
case eDomain:
aCssText.AppendLiteral("domain(\"");
break;
}
nsCAutoString escapedURL(url->url);
escapedURL.ReplaceSubstring("\"", "\\\""); // escape quotes
AppendUTF8toUTF16(escapedURL, aCssText);
aCssText.AppendLiteral("\"), ");
}
aCssText.Cut(aCssText.Length() - 2, 1); // remove last ,
return nsCSSGroupRule::AppendRulesToCssText(aCssText);
}
示例9: AppendUTF8toUTF16
void
AppendUTF8toUTF16(const nsACString& aSource, nsAString& aDest)
{
if (!AppendUTF8toUTF16(aSource, aDest, mozilla::fallible)) {
aDest.AllocFailed(aDest.Length() + aSource.Length());
}
}
示例10: AppendUTF8toUTF16
void
AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest )
{
if (!AppendUTF8toUTF16(aSource, aDest, mozilla::fallible_t())) {
NS_RUNTIMEABORT("OOM");
}
}
示例11: test_valid
PRBool
test_valid()
{
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(ValidStrings); ++i) {
nsDependentCString str8(ValidStrings[i].m8);
nsDependentString str16(ValidStrings[i].m16);
if (!NS_ConvertUTF16toUTF8(str16).Equals(str8))
return PR_FALSE;
if (!NS_ConvertUTF8toUTF16(str8).Equals(str16))
return PR_FALSE;
nsCString tmp8("string ");
AppendUTF16toUTF8(str16, tmp8);
if (!tmp8.Equals(NS_LITERAL_CSTRING("string ") + str8))
return PR_FALSE;
nsString tmp16(NS_LITERAL_STRING("string "));
AppendUTF8toUTF16(str8, tmp16);
if (!tmp16.Equals(NS_LITERAL_STRING("string ") + str16))
return PR_FALSE;
if (CompareUTF8toUTF16(str8, str16) != 0)
return PR_FALSE;
}
return PR_TRUE;
}
示例12: AppendUTF8toUTF16
void
ChromeHangAnnotations::AddAnnotation(const nsAString& aName, const nsACString& aData)
{
nsString dataString;
AppendUTF8toUTF16(aData, dataString);
AnnotationType annotation = std::make_pair(nsString(aName), dataString);
mAnnotations.push_back(annotation);
}
示例13: MOZ_ASSERT
void URL::GetHash(nsAString& aHash) const {
MOZ_ASSERT(mURI);
aHash.Truncate();
nsAutoCString ref;
nsresult rv = mURI->GetRef(ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
aHash.Assign(char16_t('#'));
AppendUTF8toUTF16(ref, aHash);
}
}
示例14: MOZ_ASSERT
/* static */ already_AddRefed<dom::Promise>
MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent)
{
MOZ_ASSERT(NS_IsMainThread());
ErrorResult rv;
RefPtr<dom::Promise> promise;
promise = dom::Promise::Create(aParent, rv);
if (rv.Failed()) {
rv.SuppressException();
return nullptr;
}
RefPtr<TaskQueue> taskQueue =
new TaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
VideoInfo config;
RefPtr<MediaDataDecoder> decoder(CreateTestH264Decoder(aBackend, config, taskQueue));
if (!decoder) {
taskQueue->BeginShutdown();
taskQueue->AwaitShutdownAndIdle();
promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to create H264 decoder"));
return promise.forget();
}
decoder->Init()
->Then(AbstractThread::MainThread(), __func__,
[promise, decoder, taskQueue] (TrackInfo::TrackType aTrack) {
nsCString failureReason;
bool ok = decoder->IsHardwareAccelerated(failureReason);
nsAutoString result;
if (ok) {
result.AssignLiteral("Yes");
} else {
result.AssignLiteral("No");
}
if (failureReason.Length()) {
result.AppendLiteral("; ");
AppendUTF8toUTF16(failureReason, result);
}
decoder->Shutdown();
taskQueue->BeginShutdown();
taskQueue->AwaitShutdownAndIdle();
promise->MaybeResolve(result);
},
[promise, decoder, taskQueue] (MediaDataDecoder::DecoderFailureReason aResult) {
decoder->Shutdown();
taskQueue->BeginShutdown();
taskQueue->AwaitShutdownAndIdle();
promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder"));
});
return promise.forget();
}
示例15: AppendUTF8toUTF16
void
URLMainThread::GetHash(nsAString& aHash, ErrorResult& aRv) const
{
aHash.Truncate();
nsAutoCString ref;
nsresult rv = mURI->GetRef(ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
aHash.Assign(char16_t('#'));
AppendUTF8toUTF16(ref, aHash);
}
}