Print Page | Close Window

CXTPPropExchangeXMLNode read/write UTF-16 problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=11518
Printed Date: 03 August 2025 at 4:41am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPropExchangeXMLNode read/write UTF-16 problem
Posted By: hipopotamo
Subject: CXTPPropExchangeXMLNode read/write UTF-16 problem
Date Posted: 21 July 2008 at 12:31pm
Hi,
 
I'm trying to save the layout of the commands bars into a string using PropExchange tool, but, everytime I put a character that is not UTF-8 in the caption of the button, I'm not able to read the string again.
 
The code is something like this...
 
CXTPCommandBars *pManager;
 
<...>

 CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
 px.SetEncoding( _T("UTF-16") );
 XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;

<...>
 
 pManager->DoPropExchange(&px, &param);
 

CString data = px.GetXML(true) );
 
// data string seems to be ok.
 
// to read the file
 
CXTPPropExchangeXMLNode px(true, 0, _T("Settings"));
 px.SetEncoding( _T("UTF-16") );
 XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
<...>

 if  (!px.LoadFromString( data )
 {
      fails!!!! because of the non utf8 character in the caption
}
 
 
I need to use UTF-16, but I'm not sure what I'm doing wrong.
 
Please note that I have a similar code for the DockingManager and it is working fine with non utf8 caractares.
 
 
Regards



Replies:
Posted By: hipopotamo
Date Posted: 22 July 2008 at 7:40am
Correction!
 
It does not work for DockingManager also.
 
A string like this one "competição"( Portuguese word, same as "competition" ) invalidates all the xml.
 
 
 
 
 


Posted By: Oleg
Date Posted: 23 July 2008 at 1:31am
Hi,
 
Do you compile with Unicode ?


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: hipopotamo
Date Posted: 23 July 2008 at 8:26am
No, i'm not using Unicode, but may be I do not need to use utf-16, i really don't know.
 
px.LoadFromString( data ) fails with this string, if i use çã instead of ca.
 
 
"><Settings CompactMode="1"> <CommandBars> <CommandBar Class="CXTPMenuBar" Type="0" BarID="1" Flags="95" Style="4194304" Title="Menu Bar" MRUWidth="32767" Closeable="0" ResourceId="132"> <Controls> <Control Class="CXTPControlPopup" Type="2" Id="1000" IconId="1000" Tag="181704656" Caption="competição" TooltipText="Popup" DescriptionText="Popup" Style="3" CommandBarId="16777216"/> </Controls> </CommandBar> <CommandBar Class="CXTPPopupBar" Type="2" Position="5" BarID="16777216" Style="4194304"/> </CommandBars> <Layout> <DockState Version="32" ScreenSize="1280, 1024" Count="1"> <BarInfo0 BarId="1" MRUWidth="32767"/> </DockState> <DockBars> <DockBar0 Count="3" Id1="1"/> </DockBars> </Layout> <Options Theme="3" Schema="32" AlwaysShowFullMenus="1" ShowFullAfterDelay="1" ToolBarScreenTips="1" ToolBarAccelTips="0" LargeIcons="0" Animation="0" SyncFloatingBars="1" ShowExpandButtonAlways="1" IconsSize="0, 0" LargeIconsSize="0, 0" IconsWithShadow="0" UseDisabledIcons="0" UseFadedIcons="1" DblClickFloat="0" ShowTextBelowIcons="0" AltDragCustomization="1" AutoHideUnusedPopups="1" PopupIconsSize="0, 0" KeyboardCuesUse="1" KeyboardCuesShow="0" Customizable="0"/> </Settings> 


Posted By: Oleg
Date Posted: 24 July 2008 at 4:32am
Hi,
Whithout Unicode you can't use Utf-16.  Utf-8 will work for you, but in this case you have to write/read directly to file.
 
instead GetXML use SaveToFile.
 
 
also try insead
 
px.LoadFromString( data )
write
px.LoadFromString( _bstr_t(data ))


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: hipopotamo
Date Posted: 24 July 2008 at 7:24am

Hi,

 I cannot read/write to a file,   I'm using a huge configuration file to write all my presentation stuff, not only codejock stuff, but also adhoc and other libs, it would be very complicated if I had a file for each one of the commandbars and dockingmanagers from xtp.

Is there any other way I can make LoadFromString to work ?

Regards



Posted By: Oleg
Date Posted: 24 July 2008 at 7:37am
Did you try px.LoadFromString( _bstr_t(data )) ?

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net