本文整理汇总了C++中NS_LossyConvertUTF16toASCII函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_LossyConvertUTF16toASCII函数的具体用法?C++ NS_LossyConvertUTF16toASCII怎么用?C++ NS_LossyConvertUTF16toASCII使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_LossyConvertUTF16toASCII函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
NS_IMETHODIMP
nsSVGGenericContainerFrame::AttributeChanged(PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aModType)
{
#ifdef DEBUG
nsAutoString str;
aAttribute->ToString(str);
printf("** nsSVGGenericContainerFrame::AttributeChanged(%s)\n",
NS_LossyConvertUTF16toASCII(str).get());
#endif
return NS_OK;
}
示例2: printf
already_AddRefed<gfxOS2Font>
gfxOS2Platform::FindFontForChar(uint32_t aCh, gfxOS2Font *aFont)
{
#ifdef DEBUG_thebes
printf("gfxOS2Platform::FindFontForChar(%d, ...)\n", aCh);
#endif
// is codepoint with no matching font? return null immediately
if (mCodepointsWithNoFonts.test(aCh)) {
return nullptr;
}
// the following is not very clever but it's a quick fix to search all fonts
// (one should instead cache the charmaps as done on Mac and Win)
// just continue to append all fonts known to the system
nsTArray<nsString> fontList;
nsAutoCString generic;
nsresult rv = GetFontList(aFont->GetStyle()->language, generic, fontList);
if (NS_SUCCEEDED(rv)) {
// start at 3 to skip over the generic entries
for (uint32_t i = 3; i < fontList.Length(); i++) {
#ifdef DEBUG_thebes
printf("searching in entry i=%d (%s)\n",
i, NS_LossyConvertUTF16toASCII(fontList[i]).get());
#endif
nsRefPtr<gfxOS2Font> font =
gfxOS2Font::GetOrMakeFont(fontList[i], aFont->GetStyle());
if (!font)
continue;
FT_Face face = cairo_ft_scaled_font_lock_face(font->CairoScaledFont());
if (!face || !face->charmap) {
if (face)
cairo_ft_scaled_font_unlock_face(font->CairoScaledFont());
continue;
}
FT_UInt gid = FT_Get_Char_Index(face, aCh); // find the glyph id
if (gid != 0) {
// this is the font
cairo_ft_scaled_font_unlock_face(font->CairoScaledFont());
return font.forget();
}
}
}
// no match found, so add to the set of non-matching codepoints
mCodepointsWithNoFonts.set(aCh);
return nullptr;
}
示例3: fprintf
void
nsXMLCDATASection::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fprintf(out, "CDATASection refcount=%d<", mRefCnt.get());
nsAutoString tmp;
ToCString(tmp, 0, mText.GetLength());
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
fputs(">\n", out);
}
示例4: switch
void
RDFContentSinkImpl::ParseText(nsIRDFNode **aResult)
{
// XXXwaterson wasteful, but we'd need to make a copy anyway to be
// able to call nsIRDFService::Get[Resource|Literal|...]().
nsAutoString value;
value.Append(mText, mTextLength);
value.Trim(" \t\n\r");
switch (mParseMode) {
case eRDFContentSinkParseMode_Literal:
{
nsIRDFLiteral *result;
gRDFService->GetLiteral(value.get(), &result);
*aResult = result;
}
break;
case eRDFContentSinkParseMode_Resource:
{
nsIRDFResource *result;
gRDFService->GetUnicodeResource(value, &result);
*aResult = result;
}
break;
case eRDFContentSinkParseMode_Int:
{
PRInt32 i, err;
i = value.ToInteger(&err);
nsIRDFInt *result;
gRDFService->GetIntLiteral(i, &result);
*aResult = result;
}
break;
case eRDFContentSinkParseMode_Date:
{
PRTime t = rdf_ParseDate(nsDependentCString(NS_LossyConvertUTF16toASCII(value).get(), value.Length()));
nsIRDFDate *result;
gRDFService->GetDateLiteral(t, &result);
*aResult = result;
}
break;
default:
NS_NOTREACHED("unknown parse type");
break;
}
}
示例5: LOG
NS_IMETHODIMP
sbWatchFolderService::OnFileSystemChanged(const nsAString & aFilePath)
{
LOG(("sbWatchFolderService::OnFileSystemChanged %s",
NS_LossyConvertUTF16toASCII(aFilePath).get()));
bool isIgnoredPath = PR_FALSE;
nsresult rv = DecrementIgnoredPathCount(aFilePath, &isIgnoredPath);
NS_ENSURE_SUCCESS(rv, rv);
// Don't bother with this change if it is currently being ignored.
if (isIgnoredPath) {
return NS_OK;
}
nsString filePath(aFilePath);
// The watcher will report all changes from the previous session before the
// watcher has started. Don't set the timer until then.
if (mHasWatcherStarted) {
// See if the changed path set already has this path inside of it.
sbStringSetIter foundIter = mChangedPaths.find(filePath);
if (foundIter != mChangedPaths.end()) {
// If this path is currently in the changed path vector already,
// delay processing this path until a later time.
mDelayedChangedPaths.insert(filePath);
// Start the delayed timer if it isn't running already.
if (!mChangeDelayTimerIsSet) {
rv = mChangeDelayTimer->InitWithCallback(this,
CHANGE_DELAY_TIMER_DELAY,
nsITimer::TYPE_ONE_SHOT);
NS_ENSURE_SUCCESS(rv, rv);
mChangeDelayTimerIsSet = PR_TRUE;
}
}
else {
mChangedPaths.insert(filePath);
rv = SetEventPumpTimer();
NS_ENSURE_SUCCESS(rv, rv);
}
}
else {
mChangedPaths.insert(filePath);
}
return NS_OK;
}
示例6: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsAbLDAPCard::SetMetaProperties(nsILDAPMessage *aMessage)
{
NS_ENSURE_ARG_POINTER(aMessage);
// Get DN
nsAutoCString dn;
nsresult rv = aMessage->GetDn(dn);
NS_ENSURE_SUCCESS(rv, rv);
SetDn(dn);
// Get the list of set attributes
CharPtrArrayGuard attrs;
rv = aMessage->GetAttributes(attrs.GetSizeAddr(), attrs.GetArrayAddr());
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString attr;
m_attributes.Clear();
for (uint32_t i = 0; i < attrs.GetSize(); ++i)
{
attr.Assign(nsDependentCString(attrs[i]));
ToLowerCase(attr);
m_attributes.AppendElement(attr);
}
// Get the objectClass values
m_objectClass.Clear();
PRUnicharPtrArrayGuard vals;
rv = aMessage->GetValues("objectClass", vals.GetSizeAddr(),
vals.GetArrayAddr());
// objectClass is not always included in search result entries and
// nsILDAPMessage::GetValues returns NS_ERROR_LDAP_DECODING_ERROR if the
// requested attribute doesn't exist.
if (rv == NS_ERROR_LDAP_DECODING_ERROR)
return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString oclass;
for (uint32_t i = 0; i < vals.GetSize(); ++i)
{
oclass.Assign(NS_LossyConvertUTF16toASCII(nsDependentString(vals[i])));
ToLowerCase(oclass);
m_objectClass.AppendElement(oclass);
}
return NS_OK;
}
示例7: fprintf
void
nsXMLProcessingInstruction::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fprintf(out, "Processing instruction refcount=%d<", mRefCnt.get());
nsAutoString tmp;
ToCString(tmp, 0, mText.GetLength());
tmp.Insert(nsDependentAtomString(NodeInfo()->GetExtraName()).get(), 0);
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
fputs(">\n", out);
}
示例8: fputs
nsresult
nsContentDLF::CreateDocument(const char* aCommand,
nsIChannel* aChannel,
nsILoadGroup* aLoadGroup,
nsISupports* aContainer,
const nsCID& aDocumentCID,
nsIStreamListener** aDocListener,
nsIContentViewer** aContentViewer)
{
NS_TIME_FUNCTION;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> aURL;
rv = aChannel->GetURI(getter_AddRefs(aURL));
if (NS_FAILED(rv)) return rv;
#ifdef NOISY_CREATE_DOC
if (nullptr != aURL) {
nsAutoString tmp;
aURL->ToString(tmp);
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), stdout);
printf(": creating document\n");
}
#endif
// Create the document
nsCOMPtr<nsIDocument> doc = do_CreateInstance(aDocumentCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Create the content viewer XXX: could reuse content viewer here!
nsCOMPtr<nsIContentViewer> contentViewer;
rv = NS_NewContentViewer(getter_AddRefs(contentViewer));
NS_ENSURE_SUCCESS(rv, rv);
doc->SetContainer(aContainer);
// Initialize the document to begin loading the data. An
// nsIStreamListener connected to the parser is returned in
// aDocListener.
rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, true);
NS_ENSURE_SUCCESS(rv, rv);
// Bind the document to the Content Viewer
rv = contentViewer->LoadStart(doc);
contentViewer.forget(aContentViewer);
return rv;
}
示例9: do_GetService
nsresult nsTestUConv::DisplayDetectors()
{
const char * trace = "DisplayDetectors";
mLog.AddTrace(trace);
nsresult res = NS_OK;
nsCOMPtr<nsICharsetConverterManager> ccMan =
do_GetService(kCharsetConverterManagerCID, &res);
if (NS_FAILED(res)) {
mLog.PrintError("NS_WITH_SERVICE", res);
return res;
}
// charset detectors
nsCOMPtr<nsIUTF8StringEnumerator> detectors;
res = ccMan->GetCharsetDetectorList(getter_AddRefs(detectors));
if (NS_FAILED(res)) {
mLog.PrintError("GetCharsetDetectorList()", res);
return res;
}
printf("***** Character Set Detectors *****\n");
bool hasMore;
detectors->HasMore(&hasMore);
while (hasMore) {
nsAutoCString detectorName;
res = detectors->GetNext(detectorName);
if (NS_FAILED(res)) {
mLog.PrintError("GetNext()", res);
return res;
}
printf("%s", detectorName.get());
PrintSpaces(36 - detectorName.Length()); // align to hard coded column number
nsAutoString title;
res = ccMan->GetCharsetTitle(detectorName.get(), title);
if (NS_FAILED(res)) title.SetLength(0);
printf("\"%s\"\n", NS_LossyConvertUTF16toASCII(title).get());
detectors->HasMore(&hasMore);
}
mLog.DelTrace(trace);
return NS_OK;
}
示例10: MOZ_ASSERT
void
GeckoMediaPluginServiceParent::RemoveOnGMPThread(const nsAString& aDirectory,
const bool aDeleteFromDisk,
const bool aCanDefer)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
LOGD(("%s::%s: %s", __CLASS__, __FUNCTION__, NS_LossyConvertUTF16toASCII(aDirectory).get()));
nsCOMPtr<nsIFile> directory;
nsresult rv = NS_NewLocalFile(aDirectory, false, getter_AddRefs(directory));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
MutexAutoLock lock(mMutex);
for (size_t i = mPlugins.Length() - 1; i < mPlugins.Length(); i--) {
nsCOMPtr<nsIFile> pluginpath = mPlugins[i]->GetDirectory();
bool equals;
if (NS_FAILED(directory->Equals(pluginpath, &equals)) || !equals) {
continue;
}
nsRefPtr<GMPParent> gmp = mPlugins[i];
if (aDeleteFromDisk && gmp->State() != GMPStateNotLoaded) {
// We have to wait for the child process to release its lib handle
// before we can delete the GMP.
gmp->MarkForDeletion();
if (!mPluginsWaitingForDeletion.Contains(aDirectory)) {
mPluginsWaitingForDeletion.AppendElement(aDirectory);
}
}
if (gmp->State() == GMPStateNotLoaded || !aCanDefer) {
// GMP not in use or shutdown is being forced; can shut it down now.
gmp->AbortAsyncShutdown();
gmp->CloseActive(true);
mPlugins.RemoveElementAt(i);
}
}
if (aDeleteFromDisk) {
if (NS_SUCCEEDED(directory->Remove(true))) {
mPluginsWaitingForDeletion.RemoveElement(aDirectory);
}
}
}
示例11: fputs
NS_IMETHODIMP
nsCSSMediaRule::List(FILE* out, PRInt32 aIndent) const
{
for (PRInt32 indent = aIndent; --indent >= 0; ) fputs(" ", out);
nsAutoString buffer;
fputs("@media ", out);
if (mMedia) {
nsAutoString mediaText;
mMedia->GetText(mediaText);
fputs(NS_LossyConvertUTF16toASCII(mediaText).get(), out);
}
return nsCSSGroupRule::List(out, aIndent);
}
示例12: SQLAllocHandle
nsresult
mozSqlConnectionODBC::RealExec(const nsAString& aQuery,
mozISqlResult** aResult, PRInt32* aAffectedRows)
{
if (!mConnection)
return NS_ERROR_NOT_INITIALIZED;
SQLHSTMT hstmt;
SQLAllocHandle(SQL_HANDLE_STMT, mConnection, &hstmt);
if(!SQL_SUCCEEDED(SQLExecDirect(hstmt, (SQLCHAR*) NS_LossyConvertUTF16toASCII(aQuery).get(), SQL_NTS))){
SetError(hstmt, SQL_HANDLE_STMT);
return NS_ERROR_FAILURE;
}
if (!aResult){
if (!aAffectedRows)
return NS_ERROR_NULL_POINTER;
SQLINTEGER count;
SQLRowCount(hstmt, &count);
*aAffectedRows = (PRInt32) count;
return NS_OK;
}
mozSqlResult *mozresult = new mozSqlResultODBC(this, aQuery);
if (!mozresult){
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
return NS_ERROR_OUT_OF_MEMORY;
}
((mozSqlResultODBC*)mozresult)->SetResult(hstmt);
nsresult rv = mozresult->Init();
if (NS_FAILED(rv)){
delete mozresult;
return rv;
}
*aResult = mozresult;
NS_ADDREF(*aResult);
return NS_OK;
}
示例13: LoadLibraryForEGLOnWindows
// see the comment in GLLibraryEGL::EnsureInitialized() for the rationale here.
static PRLibrary*
LoadLibraryForEGLOnWindows(const nsAString& filename)
{
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file));
if (NS_FAILED(rv))
return nullptr;
file->Append(filename);
PRLibrary* lib = nullptr;
rv = file->Load(&lib);
if (NS_FAILED(rv)) {
nsPrintfCString msg("Failed to load %s - Expect EGL initialization to fail",
NS_LossyConvertUTF16toASCII(filename).get());
NS_WARNING(msg.get());
}
return lib;
}
示例14: PR_LOG
nsresult
txStylesheetCompilerState::loadIncludedStylesheet(const nsAString& aURI)
{
PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
("CompilerState::loadIncludedStylesheet: %s\n",
NS_LossyConvertUTF16toASCII(aURI).get()));
if (mStylesheetURI.Equals(aURI)) {
return NS_ERROR_XSLT_LOAD_RECURSION;
}
NS_ENSURE_TRUE(mObserver, NS_ERROR_NOT_IMPLEMENTED);
nsAutoPtr<txToplevelItem> item(new txDummyItem);
NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = mToplevelIterator.addBefore(item);
NS_ENSURE_SUCCESS(rv, rv);
item.forget();
// step back to the dummy-item
mToplevelIterator.previous();
txACompileObserver* observer = static_cast<txStylesheetCompiler*>(this);
nsRefPtr<txStylesheetCompiler> compiler =
new txStylesheetCompiler(aURI, mStylesheet, &mToplevelIterator,
observer);
NS_ENSURE_TRUE(compiler, NS_ERROR_OUT_OF_MEMORY);
// step forward before calling the observer in case of syncronous loading
mToplevelIterator.next();
if (mChildCompilerList.AppendElement(compiler) == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = mObserver->loadURI(aURI, mStylesheetURI, compiler);
if (NS_FAILED(rv)) {
mChildCompilerList.RemoveElement(compiler);
}
return rv;
}
示例15:
NS_IMETHODIMP
nsMacLocale::GetPlatformLocale(const nsAString& locale, short* scriptCode, short* langCode, short* regionCode)
{
char country_code[3];
char lang_code[3];
char region_code[3];
bool validCountryFound;
int i;
if (!ParseLocaleString(NS_LossyConvertUTF16toASCII(locale).get(), lang_code, country_code, region_code, '-')) {
*scriptCode = smRoman;
*langCode = langEnglish;
*regionCode = verUS;
return NS_ERROR_FAILURE;
}
if (country_code[0]!=0)
{
validCountryFound=false;
for(i=0;country_list[i].iso_code;i++) {
if (strcmp(country_list[i].iso_code,country_code)==0) {
*regionCode = country_list[i].mac_region_code;
validCountryFound=true;
break;
}
}
if (!validCountryFound) {
*scriptCode = smRoman;
*langCode = langEnglish;
*regionCode = verUS;
return NS_ERROR_FAILURE;
}
}
for(i=0;lang_list[i].iso_code;i++) {
if (strcmp(lang_list[i].iso_code, lang_code)==0) {
*scriptCode = lang_list[i].mac_script_code;
*langCode = lang_list[i].mac_lang_code;
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}