0
我在C++中用Django中的WWW接口開發了一個應用程序。 到目前爲止,我已經在C++中使用Boost.Python包裝器編譯爲Linux中的共享對象。如何將Django unicode轉換爲C++ std :: string
現在我嘗試在Django中運行這個框架。當我經過串從形式「CharField」我得到這個錯誤:
Python argument types in
CoreSystem.setOutput(CoreSystem, unicode)
did not match C++ signature:
setOutput(CoreSystem {lvalue}, std::string)
典負責人認爲是在這裏:
form = AnalyzeForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
s.setOutput(cd["output"])
s是此CoreSystem對象。如果我這樣鍵入:
s.setOutput("DatabaseOutput")
它工作正常。我也用str(cd [「output」]),但之後沒有任何反應。
我使用Django 1.4.1和Python 2.7.3
不幸的是,當我這樣做,沒有任何反應,但沒有錯誤。我甚至把printf放在setOutput中,它不會打印任何東西。就好像setOutput根本沒有被調用。 – eclipse
你的答案有竅門。以前的錯誤是由於服務器配置錯誤。 – eclipse
另一個有趣的嘗試是將函數重載爲接受'std :: wstring'。如果Boost.Python足夠聰明,可以生成一個自動將'str'轉換爲'std :: string'的包裝器,那麼它可以將'unicode'轉換爲'std :: wstring'。 – user4815162342