problem with chinese language

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with chinese language

K. Misha
Hi!

 

Our company has developed LibOpenOffice
<http://4k.com.ua/products/others/libopenoffice?lang=en>  library for
OpenOffice automation. Our clients from China said that this code doesn't
work with chinese file path:

bool exportToUrl(char *url) {

      try {      

            int nLenOfWideCharStr =
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,NULL,0);

            wchar_t *uval = (PWSTR)HeapAlloc(GetProcessHeap(), 0,
nLenOfWideCharStr * sizeof(WCHAR));

 
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,uval,nLenOfWideCharStr);

           

            Reference<XStorable> xStore (xCalcComponent, UNO_QUERY);

            Sequence<PropertyValue> storeProps(1);

            storeProps[0].Name = OUString::createFromAscii( "FilterName" );

            storeProps[0].Value <<= OUString::createFromAscii( "MS Excel 97"
);

            xStore->storeToURL( OUString::OUString(uval), storeProps );

 

            //delete uval;

 

            return true;

      }

      catch( Exception &e ) {

        return false;

      }

}

 

Regards!

 

IT department, 4K-SOFT.

Reply | Threaded
Open this post in threaded view
|

Re: problem with chinese language

Herbert Duerr-3
On 29.04.2014 14:15, K. Misha wrote:

> Our company has developed LibOpenOffice
> <http://4k.com.ua/products/others/libopenoffice?lang=en>  library for
> OpenOffice automation. Our clients from China said that this code doesn't
> work with chinese file path:
>
> bool exportToUrl(char *url) {
>
>        try {
>
>              int nLenOfWideCharStr =
> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,NULL,0);
>
>              wchar_t *uval = (PWSTR)HeapAlloc(GetProcessHeap(), 0,
> nLenOfWideCharStr * sizeof(WCHAR));
>
>
> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,uval,nLenOfWideCharStr);
>
>
>
>              Reference<XStorable> xStore (xCalcComponent, UNO_QUERY);
>
>              Sequence<PropertyValue> storeProps(1);
>
>              storeProps[0].Name = OUString::createFromAscii( "FilterName" );
>
>              storeProps[0].Value <<= OUString::createFromAscii( "MS Excel 97"
> );
>
>              xStore->storeToURL( OUString::OUString(uval), storeProps );

Use a line such as

xStore->storeToURL( OUString::OUString(uval,nLenOfWideCharStr),
storeProps );

instead. This sets the string length explicitly instead of relying on
finding a trailing zero.

Hope that helps.

Herbert

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: problem with chinese language

Andrea Pescetti-2
Forwarding Herbert's answer in case the original poster did not get it.
Andrea

On 29/04/2014 Herbert Duerr wrote:

> On 29.04.2014 14:15, K. Misha wrote:
>> Our company has developed LibOpenOffice
>> <http://4k.com.ua/products/others/libopenoffice?lang=en>  library for
>> OpenOffice automation. Our clients from China said that this code doesn't
>> work with chinese file path:
>>
>> bool exportToUrl(char *url) {
>>
>>        try {
>>
>>              int nLenOfWideCharStr =
>> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,NULL,0);
>>
>>              wchar_t *uval = (PWSTR)HeapAlloc(GetProcessHeap(), 0,
>> nLenOfWideCharStr * sizeof(WCHAR));
>>
>>
>> MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,uval,nLenOfWideCharStr);
>>
>>
>>
>>              Reference<XStorable> xStore (xCalcComponent, UNO_QUERY);
>>
>>              Sequence<PropertyValue> storeProps(1);
>>
>>              storeProps[0].Name = OUString::createFromAscii(
>> "FilterName" );
>>
>>              storeProps[0].Value <<= OUString::createFromAscii( "MS
>> Excel 97"
>> );
>>
>>              xStore->storeToURL( OUString::OUString(uval), storeProps );
>
> Use a line such as
>
> xStore->storeToURL( OUString::OUString(uval,nLenOfWideCharStr),
> storeProps );
>
> instead. This sets the string length explicitly instead of relying on
> finding a trailing zero.
>
> Hope that helps.
>
> Herbert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: problem with chinese language

K. Misha
Hi!<неи<неиIf I'm using this code ExportToUrl function doesn't
work.<неи<неи> xStore->storeToURL(
OUString::OUString(uval,nLenOfWideCharStr),<неи> storeProps );<неи<неиHave
you some ideas?<неи<неиRegards!<неи<неи-----Original Message-----<неиFrom:
Andrea Pescetti [mailto:[hidden email]] <неиSent: Thursday, May 01,
2014 7:22 PM<неиTo: [hidden email]<неиCc:
[hidden email]<неиSubject: Re: problem with chinese
language<неи<неиForwarding Herbert's answer in case the original poster did
not get it. <неиAndrea<неи<неиOn 29/04/2014 Herbert Duerr wrote:<неи> On
29.04.2014 14:15, K. Misha wrote:<неи>> Our company has developed
LibOpenOffice<неи>> <http://4k.com.ua/products/others/libopenoffice?lang=en>
library for<неи>> OpenOffice automation. Our clients from China said that
this code doesn't<неи>> work with chinese file path:<неи>><неи>> bool
exportToUrl(char *url) {<неи>><неи>>        try {<неи>><неи>>
int nLenOfWideCharStr =<неи>>
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,NULL,0);<неи>><неи>>
wchar_t *uval = (PWSTR)HeapAlloc(GetProcessHeap(), 0,<неи>>
nLenOfWideCharStr * sizeof(WCHAR));<неи>><неи>><неи>>
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,url,-1,uval,nLenOfWideCharStr);<не
и>><неи>><неи>><неи>>              Reference<XStorable> xStore
(xCalcComponent, UNO_QUERY);<неи>><неи>>
Sequence<PropertyValue> storeProps(1);<неи>><неи>>
storeProps[0].Name = OUString::createFromAscii(<неи>> "FilterName"
);<неи>><неи>>              storeProps[0].Value <<=
OUString::createFromAscii( "MS<неи>> Excel 97"<неи>> );<неи>><неи>>
xStore->storeToURL( OUString::OUString(uval), storeProps );<неи><неи> Use a
line such as<неи><неи> xStore->storeToURL(
OUString::OUString(uval,nLenOfWideCharStr),<неи> storeProps );<неи><неи>
instead. This sets the string length explicitly instead of relying on<неи>
finding a trailing zero.<неи><неи> Hope that helps.<неи><неи>
Herbert<неи><неи>
---------------------------------------------------------------------<неи>
To unsubscribe, e-mail: [hidden email]<неи> For
additional commands, e-mail: [hidden email]<неи><неи><неи


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]