XmlLite with unicode content

Hello,
I am writing a little example of XML with some Unicode (Chinese text) in it. If I write to a file it works fine:
<?xml version="1.0" encoding="UTF-8"?><message>世界您好</message>
If I read from memory I get this:
㼼浸敶獲潩㵮ㄢ〮•湥潣楤杮∽呕ⵆ∸㸿洼獥慳敧隸闧ꢂꗥ㲽洯獥慳敧
Here is my simple code:
CComPtr<IStream> stream;
std::shared_ptr<IXmlWriter> writer;
COM_VERIFY(CreateStreamOnHGlobal(nullptr, false, (LPSTREAM*)&stream), L"CreateStream");
COM_VERIFY(CreateXmlWriter(__uuidof(IXmlWriter), (void**)&writer, nullptr), L"CreateXmlWriter");
COM_VERIFY(writer->SetOutput(stream), L"SetOutput");
COM_VERIFY(writer->WriteStartDocument(XmlStandalone_Omit), L"StartDocument");
COM_VERIFY(writer->WriteStartElement(0, L"message", 0), L"StartMessage");
COM_VERIFY(writer->WriteString(originalText.c_str()), L"OriginalText");
COM_VERIFY(writer->WriteEndElement(), L"EndMessage");
COM_VERIFY(writer->WriteEndDocument(), L"EndDocument");
COM_VERIFY(writer->Flush(), L"FlushWriter");
STATSTG ssStreamData = { 0 };
COM_VERIFY(stream->Stat(&ssStreamData, STATFLAG_NONAME), L"GetSize");
SIZE_T cbSize = ssStreamData.cbSize.LowPart;
LPWSTR pwszContent = (WCHAR*) new(std::nothrow) BYTE[cbSize + sizeof(WCHAR)];
LARGE_INTEGER position;
position.QuadPart = 0;
COM_VERIFY(stream->Seek(position, STREAM_SEEK_SET, nullptr), L"SeekPosition");
SIZE_T cbRead;
COM_VERIFY(stream->Read(pwszContent, cbSize, &cbRead), L"Read");
pwszContent[cbSize / sizeof(WCHAR)] = L'\0';
What am I missing?
Thanks,
Pedro

Since the default output encoding is UTF-8, you cannot reinterpret the data as Unicode using the
pwszContent pointer. For debugging purposes you can cast it:
    LPCSTR p = (LPCSTR)pwszContent;
Then you will see a more valid content in Visual Studio, excepting the non-Latin letters.
In fact, the buffer (pwszContent) should be declared as
LPSTR instead of LPWSTR, since it is UTF-8.
In order to cast to Unicode:
    WCHAR ws[1000];
    MultiByteToWideChar( CP_UTF8, 0, p, -1, ws, 1000 );
Then you can assign it to wstring. To work with any length, see
MultiByteToWideChar.
In order to change the output encoding, consider the features related to
IXmlWriterOutput.

Similar Messages

  • Technical upgrade from 4.6c to 6.0ecc with unicode conversion

    Hi Experts,
    Can you explain me technical upgrade from 4.6c to 6.0ecc with Unicode conversion.
    if u got any notes pls send it to [email protected]
    vijay

    Check these links. Search SDN  with Term "Upgradation" you will get lot of links
    http://help.sap.com/saphelp_nw04/helpdata/en/16/4b3c88170e11d6999d00508b6b8b11/frameset.htm
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0f9f37c-be11-2a10-3baf-d5d7de5fb78d
    http://www.sdn.sap.com/irj/sdn/wiki?path=/display/unicode/system%2blandscape%2bconversion
    http://www.sdn.sap.com/irj/sdn/wiki?path=/display/unicode/project%2bplanning%2b-%2bmdmp%2bsystem
    http://www.sdn.sap.com/irj/sdn/wiki?path=/display/unicode/communication%2binterfaces
    Message was edited by: Jason Lax (Removed link to deleted content)

  • MaxDB upgrade/heterogeneus system copy problem with unicode conversion

    Project goal:
    upgrade a Content Server Version 7.3.0.35   32bit Non Unicode to
    version 7.6.06.16   64bit Unicode
    I found and followed note 962019
    My plan (following the note): 
    -create a clone of the original Content Server (vmware clone)
    -as per note 962019 patched server 7.3.0.35 to 7.3.0.62 (> 7.3.0.57)
    -created index
    -on a fresh installed windows 2003 server 64bit i installed Content Server with build 7.6.06.16
    -using loadercli from the target server (7.6.06.16) exported data
    Now i was ready to start the import, as the note states:
    "if the database parameter _UNICODE is set to the value NO and you want to start the target system with SAP MaxDB Version 7.6, you can use procedure described here for the import into a target system only with SAP MaxDB Version 7.6.05 build 11 or higher"
    Having version 7.6.06.16 i was confident on such procedure, but my import stops immediatly with error:
    D:\exportKpro>loadercli -d PRD -u SAPR3,SAP -b import.sql
    Loader protocol: 'C:\Documents and Settings\administrator\My Documents
    \sdb\loader\log\loader.log'
    Loader packages: 'C:\Documents and Settings\administrator\My Documents
    \sdb\loader\packages'
    Error connecting user SAPR3 to database PRD on local host: -25005
    User (SAPR3) logon to database PRD failed: SQL error -8046 = Conversion from UNI
    CODE impossible: 7600 (error position: 1)
    And now i'm stuck with no hints on how to proceed.
    Thanks in advance.
    Regards
    Simone Zaffalon

    Hello Simone,
    as you're staying on Windows platform, there is no need for a heterogenous system copy.
    All you've to do is to upgrade the 32-Bit installation to your target release (why not use MaxDB 7.7 right away?).
    Once this is done, you can check whether the database catalog is still non-unicode (_UNICODE=FALSE).
    If it is, there is a catalog migration procedure you can use to change this.
    If the 32-Bit database is as you want it, take a full data backup.
    Then uninstall the 32-Bit software, install the same version of MaxDB in the 64-Bit fashion.
    Finally create the db instance by a restore of the backup.
    After a load_systab your database is fully ready to go!
    Just to stress this again: the _UNICODE parameter is not about your data!.
    It's about the database catalog.
    Having this parameter set to YES you can create e.g. tables named with Unicode characters.
    The parameter does in no way affect your business data!
    Since many customers ask why they should't use loadercli for a scenario like this:
    a) It's only supported if you must use it, that is, you change the byte-order of the OS platform
    b) it's way faster than export and import. We're talking about a few hours compared to days here!
    c) It's much safer and controllable to use backup/restore and SDBUPD and move on step-by-step than exporting all data into a big file chunk and hoping that everything will be fine afterwards.
    regards,
    Lars

  • Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content?

    Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content? By anyone, I mean someone who can download and use the free Adobe Reader, on either a Mac or PC. I have Acrobat Pro, and would like to be able to create forms that can not only be filled out and printed, but saved and emailed, which is not an option with the forms I have created to date. They can be filled out, but not saved, with Adobe Reader.
    TIA,
    Nancy

    To do what Dave indicated you need to do, it depends on what version of Acrobat you have:
    Acrobat 8: Advanced > Enable Usage Rights in Adobe Reader
    Acrobat 9: Advanced > Extend Features in Adobe Reader
    Acrobat 10: File > Save As > Reader Extended PDF > Enable Additional Features
    Acrobat 11: File > Save as Other > Reader Extended PDF > Enable More Tools (includes form fill-in & save)
    I wonder what it will be next time?

  • I have a new iPhone 5S.  While trying to learn about it, I accidentally recorded a voice memo with no content.  I cannot now figure out how to get rid of it.  There is a banner across the top of my phone with this memo which I don't want.  Help!

    I have a new iPhone 5S.  While trying to learn about it, I accidentally recorded a voice memo with no content.  I cannot now figure out how to get rid of it.  There is a banner across the top of my phone with this memo which I don't want.  I have deleted it from iTunes but cannot get it off the phone.  Help!

    The banner usually indicates that the memo is "Paused." If you go back into voice memos, touch the word "Done" beside the big red pause button, give it a name, then it will show in a list. Touch the memo in the list then touch the trash can icon that should appear.

  • How do I fill an Excel spreadsheet with the contents of a DataTable? (C#, OleDb)

    The following fills a DataTable with the contents of an Excel spreadsheet.
        oledbCmd.CommandText = "SELECT * FROM [" + stSheetName + "$]";
        DataTable dtDataTable = new DataTable();
        using (OleDbDataAdapter oledbAdapter = new OleDbDataAdapter(oledbCmd))
        oledbAdapter.Fill(dtDataTable);
    How do I fill an Excel spreadsheet with the contents of a DataTable?
    bhs67

    You can try this Excel library, it can help u to
    export datatable to excel to Database.
    After add the reference to your project ,add the following code:
    private void button1_Click(object sender, EventArgs e)
    //connect database
    OleDbConnection connection = new OleDbConnection();
    connection.ConnectionString @"Provider=""Microsoft.Jet.OLEDB.4.0"";Data Source=""demo.mdb"";User Id=;Password="
    OleDbCommand command = new OleDbCommand();
    command.CommandText = "select * from parts";
    DataSet dataSet = new System.Data.DataSet();
    OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command.CommandText,connection);
    dataAdapter.Fill(dataSet);
    DataTable t = dataSet.Tables[0];
    //export datatable to excel
    Workbook book = new Workbook();
    Worksheet sheet = book.Worksheets[0];
    sheet.InsertDataTable(t, true, 1, 1);
    book.SaveToFile("insertTableToExcel.xls");
    System.Diagnostics.Process.Start("insertTableToExcel.xls");
    http://www.e-iceblue.com/Tutorials/Spire.XLS/Spire.XLS-Program-Guide/Data-Export-/Import-Export-Datatable-to-Excel-from-Database.html

  • Create a site collection with dedicated content db with the help of server object model

    Hi,
     I have a requirement to implement a create a new site collection with dedicated content db. i have got 2 PowerShell scripts which does the same. first i will  create a content  db and then create the sitecollection with contentdb
    parameter with the created contentdb name.
    Now the site collection created must contain few doc libs and few splists with look up columns, people picker data type, multiline of text, single line of text,choice field. hence i am thinking the below approach:
     1) create a web template and include sp doclibs, splists , site columns in this.
     2) i am thinking of a ui design to create the below:
     These are called "projects" which is actually the site collection with the doclibs, splists and must be created by sharepoint admin on click of a link in my landing page.end users access these "projects"  aka 
    "site collections" and uploads the documents into these projects and collaborate.
    so my question is :  On click of a button can I create a site collection with a dedicated content db based on the web template created with the  hel of  server  object model?
    The other approach is on click of this button call the power shell script which accepts the sitecollection name and contentdb name as parameter. is this possible in  server obj.model ?
    passing a paramter from code behind- visual web part ui to power shell ?
    and it should create the site collec based on the web template and create the content db.
    my doubt #3 : will it not throw error "request timed out" when creating the site collec and contentdb from ui ?

    Try below:
    http://sharepoint.stackexchange.com/questions/21606/programmatically-create-a-site-collection-in-an-existing-mounted-content-databa
    PowerShell is just a wrapper for the object model. You shouldn't need to reference PowerShell in your feature, just create the new site collection with C# inside your feature. There's a blog post here that illustrates some code that may get you started.
    http://blog.mastykarz.nl/programmatically-creating-sites-site-collections-custom-web-template/
    http://blogs.msdn.com/b/vesku/archive/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom.aspx
    # Enable the remote site collection creation for on-prem in web application level
    # If this is not done, unknon object exception is raised by the CSOM code
    $WebApplicationUrl = http://dev.contoso.com
    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if ($snapin -eq $null)
    Write-Host "Loading SharePoint Powershell Snapin"
    Add-PSSnapin "Microsoft.SharePoint.Powershell"
    $webapp=Get-SPWebApplication $WebApplicationUrl
    $newProxyLibrary = New-Object "Microsoft.SharePoint.Administration.SPClientCallableProxyLibrary"
    $newProxyLibrary.AssemblyName = "Microsoft.Online.SharePoint.Dedicated.TenantAdmin.ServerStub, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
    $newProxyLibrary.SupportAppAuthentication = $true
    $webapp.ClientCallableSettings.ProxyLibraries.Add($newProxyLibrary)
    $webapp.Update()
    Write-Host "Successfully added TenantAdmin ServerStub to ClientCallableProxyLibrary."
    # Reset the memory of the web application
    Write-Host "IISReset..."
    Restart-Service W3SVC,WAS -force
    Write-Host "IISReset complete."
    If this helped you resolve your issue, please mark it Answered

  • Document Creation error - "We're sorry. We can't open document name because we found a problem with its contents"

    Morning Friends,
    I have created a SharePoint 2010 "Site Workflow" that is designed to take information from a form and create a Word doc with the gathered information and store this Word doc in a document library.
    I am using Sharepoint 2013 with Office 2013 
    I understand there are a lot of steps (19) outlined below and I can provide more information as needed but the bottom line is this, workflow successfully takes info from an initiation form, uses the info to create a Word doc. Places this Word doc in a library.
    When attempting to open / edit doc, receive error
    "We're sorry. We can't open <document name> because we found a problem with its contents"
    Details - No error detail available.
    Any info or advice would be greatly appreciated. 
    Very high level view of what I have done:
    1 - Created content type called "Letters"
    2 - Added site columns " First Name" and "Last Name"
    3 -  Created and saved to my desktop a very basic Word document (Letter.docx) that says "Hello, my name is XXXX XXXX"
    4 - In the advanced settings of the "Letters" content type I uploaded this "Letter.docx" file as the new document template.
    5 - Created a new document library called "Letters"
    6 - In Library Settings - Advanced Settings, clicked "Yes" to enable the management of content types.
    7 - Then I clicked "Add from existing content types" and added the "Letters" content type
    8 - Back in the advanced settings of the "Letters" content type I selected "Edit Template" and replaced the first XXXX with the Quick Part "First Name" and the second XXXX with the Quick part "Last Name"
    9 - Created a new 2010 Site workflow called "Create a Letter"
    10 - To the workflow I added the action "Create List Item"
    11 - Configured the action to create Content Type ID "Letters" in the document library "Letter" 
    12 - For the "Path and Name" I gave it a basic name of "Letter to"
    13 - The next step was to create the Initiation Form Parameters and added to form entries "First Name" and "Last Name"
    14 - I then linked the initiation form fields to the data source "Workflow Variables and Parameters" to their respective Field from Source parameters
    15 - Went back to the "Path and Name" and modified the basic name of "Letter to" to include the first and last name parameters.
    16 - Saved - published and ran the work flow.
    17 - As expected, Initiation Form prompts for First and Last Name. ("John Doe") Then click "start
    18 - Go to document library "Letters" and see a new Word document created titles "Letter to John Doe" 
    19 - Go to open / edit the Word document and receive the following error
    thoughts? Any info or advice would be greatly appreciated. 

    See this MS support article for SP2010 workflows and generating Word docs:
    https://support.microsoft.com/kb/2889634/en-us?wa=wsignin1.0
    "This behavior is by design. The Create
    List Item action in the SharePoint
    2010 Workflow platform can't convert Word content type file templates to the correct .docx format."
    I've had success in using SP 2013, Word 2013 (saving a .docx as the template instead of .dotx for the document library content type), and an SP 2010 workflow using SP Designer 2013.

  • Error message in .docx : 'Open XML file cannot be opened because there are problems with the contents. Details Unspecific error Location: 2'

    I have put a lot of work into a docx document on my Mac, but now can't open it as it gives the error message: 'the Open XML file cannot be opened because there are problems with the contents. Details, Unspecific
    error, Location: 2'
    When opening the original file the message said: 'this file contains word 2007 for Windows equations' etc. but I managed to track changes fine, and saved, closed and re-opened it numerous times without problem. Some graphs seemed moved, and various formulas
    were illegible, but no other weirdness was observed.
    I have microsoft 2008 installed on my Mac OS X version 10.6.8.
    I've tried to fix it using various solutions suggested here, but am afraid am too IT illiterate to have had any luck, please help I'm new to all this!
    I've uploaded it to https://www.dropbox.com/s/hkw9k6lyihzoxpc/SittwayPauktawSQUEACREPORT_KD%2BCH.docx

    Hi,
    This issue is related strictly to oMath tags and occurs when a graphical object or text box is anchored to the same paragraph that contains the equation.
    Please use the "Fix it" tool in the following KB article to resolve the problem. See:
    http://support.microsoft.com/kb/2528942
    Hope this helps.
    Regards,
    Steve Fan
    TechNet Community Support

  • CRVS2010 Beta - Cannot export report to PDF with unicode characters

    My report has some unicode data (Chinese), it can be previewed properly in the windows form report viewer. However, if I export the report document to PDF file, the unicode characters in exported file are all displayed as a square.
    In the version of Crystal Report 2008 R2, it can export the Chinese characters to PDF when I select a Chinese font in report. But VS2010 beta cannot export the Chinese characters even a Chinese font is selected.

    Barry, what is the specific font you are using?
    The below is a reformatted response from Program Management:
    Using non-Chinese font with Unicode characters (Chinese) the issue is reproducible when using Arial font in Unicode characters field. After changing the Unicode character to Simsun (A Chinese font named 宋体 in report), the problem is solved in Cortez and CR both.
    Ludek

  • How can I replace my iTunes Library with the contents of my iPod, including the playlists?

    I tried transferring the purchases, but it didn't move my playlists over. I have also tried backing my old library up to a disc, and putting it in my new computer, but it still didn't transfer my playlists.
    Is there any way I can transfer my old itunes library from my old computer to my new computer, including the playlists?
    I have heard people talk about replacing itunes with the contents of the ipod, but I'm not sure how to do it.

    check out this post by Zevoneer.
    if you have an iPod Touch, there are PhoneView and iRip.
    as for playlists, check out the posts by Chris CA in this discussion.

  • How can I have multiple WINDOWS (NOT tabs) with INDEPENDENT content?

    How can I have multiple '''windows''' (''not ''tabs) with '''independent''' content?
    I used to be able to open separate windows with Firefox, and the content could be completely different in each window. No matter what I did in any window, no OTHER window open at the time, nor any of the content therein, was affected. This is no longer the case and it is extremely frustrating for me.
    I do ''not ''like tabs and do not use them. I prefer multiple windows plus I am so used to using them, for so many years now! But with v9.0.1 I suddenly can no longer do what I've always done with my browser without this aggravating problem constantly reminding me that I can't have what I want in firefox anymore.
    Or can I? Does anyone have a solution I don't realize exists?
    Thanks,
    Sowelu

    AppleScriptObjC can use pretty much everything in the Cocoa API, so yes, it is possible.
    Note that a view is not the same as a window, and a window can have multiple views. There are also many ways to implement "tabs";  take a look at some of Apple's applications - they use various mixtures of toolbars, checkboxes, and radio buttons, for example.  An application such as this will be a lot more involved than what you have done so far though, using custom classes and subclassing existing ones, so be prepared to do a lot of reading and researching.

  • How to copy a page( webpart page) with its content using client side.

    How to copy a page(in my case  webpart page) with its content(it may contain webparts) using client code (i mean using SPservices or ECMA script).
    What i am planning is ,to give end user a page where it will contain text box to specify  name of page and a button with the help of  content editor webpart.
    where on click of button we need to write client side code such that it should create a new page from a existing page in a library with given name by user.
    Any suggestion would be helpful. For your information we can do it through UI with the help Site Actions / Manage Content and Structure.But i want to automate it using client side code.Server side code is restricted.
    or can we create a template of an existing page with content without the help of sharepoint designer.
    Thanks in advance
    with regards Ravichandra

    This is good example
    http://balajiindia.wordpress.com/2011/05/27/using-jquery-with-custom-web-services-in-sharepoint/
    Create web service
    http://balajiindia.wordpress.com/2011/05/27/using-jquery-with-custom-web-services-in-sharepoint/. Create method "Create Page" http://www.learningsharepoint.com/2010/09/17/create-publishing-pages-sharepoint-2010-programmatically/
    Build your Java Script. You can use Content Editor Web Part if you want to avoid custom web part development http://www.codeproject.com/Articles/544538/JQuery-with-SharePoint
    Oleg

  • Firefox is stumbling when pages with PDF content come up. how can i get my old version3.5.6 back?

    Question
    firefox is stumbling when pages with PDF content come up. how can i get my old version3.5.6 back?

    Thanks for your response Cor el, I'll try that the next time it happens, it's completely random. One moment it functions normally then suddenly it changes its mind.
    Restarting my pc usually brings it back to normal until next time.
    One thing I've noticed, but not 100% sure there's a connection here.....I edit my websites online and log into cpanel which opens new pages in separate tabs, as it should do. It seems that this problem occurs when I'm logged into cpanel...if i'm logged in then open a new tab for regular browsing of other sites then all links on those sites also open in new tabs.
    Ican't say for sure if it's always only happened when logged into cpanel, but certainly on the last 3 occasions.
    At the moment it's behaving normally so much I can do to check your suggestions, but will try them the next time it occurs.
    One other thing I forgot to mention too....since i've had the new firefox, I've noticed that when I log into yahoo and post comments, I often find myself having to log on for each new post. Everything was fine with old firefox and there have been no other changes to my pc .

  • HT4859 I have an iPhone 5 and have just set up the iCloud for it. I also have an iPad with different content and I also want to connect it to iCloud. Will I lose everything that's on my iPad or iPhone or do they sync together without losing anything?

    I have an iPhone 5 and have just set up the iCloud for it. I also have an iPad with different content and I also want to connect it to iCloud. Will I lose everything that's on my iPad or iPhone or do they sync together without losing anything?

    The problem is that all services are bundled with your Apple ID ([email protected]):
    Your iCloud account (Mail, Contacts, Calendars, Reminders, Notes, Backups, etc.),
    also iTunes & App Store purchases (Music, Movies, TV Shows, etc.),
    and the iTunes Match services.
    (I guess that all your devices - yours and your wife's are connected to one iTunes library, right?)
    If you want that your wife gets her own iCloud account for Mail, Contacts, Calendars, etc. but gets also access to your media then you have two set up two things on her device:
    iCloud (Settings > iCloud) with her account (e.g. [email protected])
    and
    iTunes & App Stores (Settings > iTunes & App Stores) with your account (e.g. [email protected]).
    In this case she gets access to your library and could use the same iTunes Match account.
    (See also: Using one Apple ID for iCloud and a different Apple ID for Store Purchases http://support.apple.com/kb/HT4895)

Maybe you are looking for