[MacRuby-devel] UTF8 Strings

Brian Chapados chapbr at gmail.com
Sun Dec 6 18:18:44 PST 2009


On Sun, Dec 6, 2009 at 3:02 PM, S. Ross <cwdinfo at gmail.com> wrote:
> Yes, well I did read the documentation but thanks for the suggestion. I just
> mistyped in my email. I'm also specifying the Cocoa framework.
>
> None of that seems to explain why initWithData:error returns null.

In the original code you showed, you were passing an NSMutableString
object to initWithData:options:error:. If you want to use
initWithData:options:error: you need to convert your string to a data
object:

xml_data = s.dataUsingEncoding(NSUTF8StringEncoding)

Or, if the source data is coming from some other source, you might be
able to create an NSData object directly.

> I'll give it another whirl.
>
> Hunted and pecked from my iPhone
>
> On Dec 6, 2009, at 2:27 PM, Vincent Isambart <vincent.isambart at gmail.com>
> wrote:
>
>>> * initWithString is simply unrecognized as a method
>>
>> Please look at the documentation first. It's initWithXMLString not
>> initWithString
>>>
>>> * NSXMLDocumentTidyXML constant is not defined so I just transcribed the
>>> equivalent bitshift
>>
>> If you do framework 'Cocoa', NSXMLDocumentTidyXML is properly defined...
>>>
>>> * The resultant XML document is null
>>
>> It works fine if you use initWithXMLString:options:error:
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>


More information about the MacRuby-devel mailing list