Cannot instantiate PDFDoc instance when apostrophe in filename

Question:

When I call PDFDoc doc(szFileName); and szFileName contains an apostrophe in it there is an exception.

Answer:

Since you are using C++ unfortunately C++ never got “strings” correct with regards to Unicode, and a std::string have no known encoding. As such PDFTron SDK has to assume an encoding, which is UTF8, but that is often enough not correct.

https://www.pdftron.com/api/PDFTronSDK/cpp/classpdftron_1_1_p_d_f_1_1_p_d_f_doc.html#a82ef303f66bf212280dc82be2573fa17

Instead, please create a UString object with your string, and pass the UString to the PDFDoc constructor.

https://www.pdftron.com/api/PDFTronSDK/cpp/classpdftron_1_1_p_d_f_1_1_p_d_f_doc.html#a01413dce319bc93dd6eced5077d435a5

https://www.pdftron.com/api/PDFTronSDK/cpp/classpdftron_1_1_u_string.html#a149883f0170576404954b67e43e51cab

With UString you can pass in other encodings.

https://www.pdftron.com/api/PDFTronSDK/cpp/classpdftron_1_1_u_string.html#aec9721b3eb2544b478a7a44b3030b1cc