SOAPEngine icon indicating copy to clipboard operation
SOAPEngine copied to clipboard

Tabulation character not displayed whereas accents are working

Open natoli66 opened this issue 6 years ago • 13 comments

Hi everybody,

I'm currently using latest version (1.40.4) and I have a weird bug, I really hope you can help me figuring out what it is.

So I'm using the engine to get some data from my website and for some reason accents and special chars are displayed and work perfectly, example : French sentence I receive : "S'est adapt\U00e9 rapidement \U00e0 son poste"

Whereas a tab character is not displayed I get "RESOCPRO_69_94_A-VII" which should be "RESOCPRO_69_94_A-VII\u0009"

I tried to print data as utf8 encoded this way

func soapEngine(_ soapEngine: SOAPEngine!, didBeforeParsingResponseData data: Data!) -> Data! {
        print(String(data: data, encoding: .utf8))
        return data
}

And I got "RESOCPRO_69_94_A-VII\t" we can see that the tabulation is present.

The thing is that I can't return the right data...

I really don't understand why accents are working and not tabs thought, I tried to get the same data using php soap client and it worked.

natoli66 avatar Aug 29 '17 12:08 natoli66

Please, download the last updated version 1.40.5.

Thanks.

priore avatar Aug 29 '17 17:08 priore

Thank you for your fast answer but I updated and it is still not working... I have the same result.

Btw I don't know if I understood well the update you made but I don't think my server is sending both unicode and utf8 (I don't know the subject really well either but I know my server only sends data encoded the same way).

Trying to help here but I might have failed, still I can help you if you have any question.

natoli66 avatar Aug 30 '17 09:08 natoli66

Please, verify the version on your SOAPEngine, on .h file, from our tests the text conversion containing accented letters or unicode characters or both, is right.

priore avatar Aug 30 '17 10:08 priore

// Version : 1.40.5

The thing is I don't think my server is sending unicode, I don't know how I can help maybe I can send you the raw request response ?

natoli66 avatar Aug 30 '17 10:08 natoli66

Ok, you can send us the xml, base64 encoded from the nsdata returned by the didBeforeParsing delegate?… also by email if you prefer.

thanks for your patience.

2017-08-30 12:09 GMT+02:00 Anthony Natoli [email protected]:

// Version : 1.40.5

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/priore/SOAPEngine/issues/168#issuecomment-325946250, or mute the thread https://github.com/notifications/unsubscribe-auth/ABd1Rk44DLJb7ihl8XtfynrZRGwI0mK7ks5sdTTCgaJpZM4PFz2G .

priore avatar Aug 30 '17 10:08 priore

I've sent an email to [email protected].

natoli66 avatar Aug 30 '17 10:08 natoli66

The internal XML parser of SOAPEngine truncate the invalid characters for default, we know this is a limitation but with the next version (2.0) this limitation will no longer exist, why we will totally change the parser.

In the waiting can replace the parser following the information of this TBXML link, obtaining an increase of speed, this should also solve the problem.

priore avatar Aug 30 '17 12:08 priore

Do you have any tip on how to install TBXML I download your version with cocoapods but it seems that the bridging header I made doesn't work, still I have 50 errors pointing directly at TBXML framework.

natoli66 avatar Aug 30 '17 14:08 natoli66

Sorry, for Swift use the UTXMLDictionary pod, it that is based on TBXML:

import UIKit
import SOAPEngine64
import UTXMLDictionary

class ViewController: UIViewController, SOAPEngineDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let soap = SOAPEngine()
        soap.responseHeader = true
        soap.actionNamespaceSlash = true
        soap.delegate = self
        
        soap.setValue("Genesis", forKey: "BookName")
        soap.setIntegerValue(1, forKey: "chapter")
        soap.requestURL("http://www.prioregroup.com/services/americanbible.asmx",
                        soapAction: "http://www.prioregroup.com/GetVerses")
        
    }
    
    func soapEngine(_ soapEngine: SOAPEngine!, didBeforeParsingResponseData data: Data!) -> Data! {
        
        let dict = UTXMLDictionary.dictionary(fromXMLData: data) as! [String : AnyObject]
        debugPrint(dict)
        
        return nil
    }
    
    func soapEngine(_ soapEngine: SOAPEngine!, didFailWithError error: Error!) {
        
        debugPrint(error)
    }

}

priore avatar Aug 30 '17 19:08 priore

Thanks for giving me this link, but I still have the same problem even with UTXMLDictionary when I print data the way you showed me, the tabulation character is still not present. But it's okay I think I'll find another way to solve it until you release the v2, do you plan on releasing it soon though ?

natoli66 avatar Aug 31 '17 08:08 natoli66

Hello, add pod declaration as below, before UTXMLDictionary pod, is a modified version to recover the original value without lose spaces or special characters like the tabulator.

pod "TBXML", :git => 'https://github.com/priore/TBXML.git'

priore avatar Aug 31 '17 09:08 priore

Getting those 50 build time errors again concerning TBXML as when I tried to use it alone...

natoli66 avatar Aug 31 '17 09:08 natoli66

For now the only solution found is to import directly the TBXML classes (from the GitHub Priore), then remove them from the pod TBXML and UTXMLDictionary and use the TBXML cetegory that exposes the TBXML.dictionary(withXMLData: ..) method, but remember to add the libz library (Target -> Build Phases -> LInk Binary...) and import TBXML and TBXML+NSDictionary in the bridge file.

priore avatar Aug 31 '17 13:08 priore