Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: problem in getting WString Attribute



XMLCh and wchar_t are not synonymous under Xcode; XMLCh is 16 bits wide, typedef'd from unsigned short, while wchar_t is 32 bits wide. Since getAttribute returns a const XMLCh*, this shouldn't even be compiling (std::wstring doesn't have a constructor that matches XMLCh*). Unless, of course, you've changed wchar_t to be a short with -fshort-wchar, in which case you have to provide all the wchar_t library functions yourself (which may explain the app termination problem if you're weak-linking against those functions; you're trying to call unresolved symbols).

Another approach is to typedef something like this:

#if TARGET_OS_MAC
typedef UniChar utf16char;
typedef std::basic_string<UniChar> utf16string;
#elif _WIN32
typedef wchar_t utf16char;
typedef std::wstring utf16string;
#endif

And use utf16char/utf16string everywhere instead of explicitly referencing wchar_t and std::wstring. I believe UniChar and XMLCh are synonymous under Xcode (both are unsigned shorts).

-Iván
---
Iván Cavero Belaunde (email@hidden)
Flash Video Architect
Adobe Systems Inc.

> -----Original Message-----
> From: xcode-users-bounces+icavero=email@hidden [mailto:xcode-
> users-bounces+icavero=email@hidden] On Behalf Of Aby
> Sent: Thursday, July 27, 2006 2:58 AM
> To: xcode-users at apple.com
> Subject: problem in getting WString Attribute
> 
> Hi,
> 
>     I am porting one application to mac OS X from windows. Windows
> application is using xerces, I haven't used xerces earlier,   now
> downloaded the source and made a framework and included in the
> project....., but my application terminate from the following funtion
> GetWStringAttribute()
> 
> //------------
> 
> std::wstring GetWStringAttribute( DOMNode* pnode, char* pAttributeName)
> {
>      DOMElement* pElement = static_cast<DOMElement*> (pnode);
>      return std::wstring( pElement -> getAttribute( Transcode (
> pAttributeName)));
> }
> 
> //-------------
> 
> XMLCh* Transcode( const char* pstr )
> {
>         static  XMLCh   achBuffer[2048];
>         XMLString::transcode(pstr,  achBuffer,2047);
>         return achBuffer;
> }
> 
> //--------------
> 
> could anyone please she
> 
> thanking in advance
> 
> Aby
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/xcode-users/email@hidden
> 
> This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >problem in getting WString Attribute (From: Aby <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.