Save to pdf from a weird string - iphone

From my XML file, I got a weird string (I think it's a blob data).
It looks like this:
0x244033242D212E430D21E2E3[.......]
It's a very very long string. My DB administrator told me that it comes from the database.
How to convert this string to a valid PDF file?
Thank you very much.
Regards,
Kael

A lot depends the database's manner of storing blob data, but if the format's not too exotic then the NSData and NSPropertyListSerialization classes should be able to convert it into something manageable.

Related

MongoDB $bitsAllClear with BinData - how it works?

Does anyone knows how the mongodb $bitsAllClear works?
I ready the document from https://docs.mongodb.com/manual/reference/operator/query/bitsAllClear/ i am trying to understand how can i create a BinData from a bitmask
For example the documentation says:
(the binary representation of BinData(0, "ID==") is 00010100.
How can i transform the 00010100 to binary to insert in the document? Is there any online converted to try?
(the binary representation of BinData(0, "ID==") is 00010100.
This example looks incorrect to me. BinData takes a base64 encoded string as its second argument, and the base64 encoding of 00010100 is FA==. Other examples on that same page look correct, so I suspect it's a typo.
In node, you can do the conversion from a binary string to base64 like so:
const hexString = parseInt('00010100', 2).toString(16);
Buffer.from(hexString, 'hex').toString("base64") // FA==
Online tool to test out encodings here -> https://cryptii.com/pipes/binary-to-base64

MongoDB insert \u0000 after each character in string field?

I am just started mongodb and facing issue when saving XML in string field. it add '\u0000' with each character in xml file. like
"\u0000?\u0000x\u0000m\u0000l\u0000 \u0000v\u0000e\u0000r\u0000s\u0000i\u0000o\u0000n
I need to save this XML as it is without JSON 0r BSON conversion in string field.
Till the time, I found a query to get xml back in correct format.
db.Test.find({"data":"XYZ"}).forEach(function(doc){
var xml = doc.data.replace(/\u0000/g,"");
print(xml);
})

Convert specific symbols to normal utf-8 from json

I get json string from server. Then I parser it using SBJSON library. But when I show parse results in my label I have symbols like that
!
(normally it's !).
So how can I convert my json string to normal string?
Use this: https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m (specifically, the stringByDecodingHTMLEntities method).

Parsing new Date in JSON

I am making a request for data and parsing it in JSON format however I do get errors because it returns timestamps in the javascript form new Date(1500000). How do I go about fixing this issue.
I thought of using regex to put quotes around the new Date(0000000) but it doesn't seem to work. I am using RegexKitLite and SBJSON. Thanks in advance for the help
You can simply use;
value = new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
where value is your "Date(1500000)" string.

xml parser, in iPhone

Am getting date (10/02/2011) in xmlresponse how to get this value in to string using NSXmlParserDelegate. "/" blocks me and am not getting how to handle this..
Thanks in advance..
Use NSDateFormatter to get date from NSString from any formats.
You have not been clear where this xml data is coming from, I couldnt turn anything up on how dates should be formatted in xml. The first thought is "you are doing it wrong" if you can try using a different separator for dates, parse them out of the stream before you give the data to NSXMLParser. I know which I would prefer.