Mailing Lists: Apple Mailing Lists

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

CW to Xcode: basic_ostream<UniChar...> and << "ascii"



Hi,

CW's C++ ostream classes allow you to to create a type like this:

typedef std::basic_ostream<UniChar, std::char_traits<UniChar> >
TCLostream;

(UniChar is a 16-bit int) and then to output (char*) string literals through
it like this in code:

{
    TCLostring output(...);

    output << "Hello World" << std::endl;
}

When I run this from Xcode, the GNU C++ library throws a bad cast exception.
What must I do to support this.  I have a mountain of code that uses this
approach, so I'm sort of stuck.

Similarly, I have code that uses MSL's std::__utf8 to output UTF-8 encoded
text from a 16-bit (UniChar) C++ ostream:

typedef std::basic_string<UniChar, std::char_traits<UniChar>,
std::allocator<UniChar> > TCLString;


    std::locale loc(std::locale(), new std::__utf_8<UniChar>);
    TCLofstream o("/Users/mall/Desktop/test.txt");
    o.imbue(loc);

    TCLString utf16Variable(...);
    o << utf16Variable << std::endl;

What's the best solution for this problem?  I'm wondering if I should try
and port MSL's implementation of std::__utf_8 to GNU-C or if there is a
GNU-Cish way to accomplish the same thing.

Thanks
-Mark
 
------------------------------------------------------------------------
Mark Alldritt                      Late Night Software Ltd.
Phone: 250-380-1725                Script Debugger 4.0 - AppleScript IDE
WEB:  http://www.latenightsw.com/  FaceSpan 4.3 - AppleScript RAD
                                   Affrus 1.0 - Perl Debugging


 _______________________________________________
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



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.