11

मैं MongoDB में एक init फ़ाइल डाला है:MongoDB विशेष वर्ण

db.User.insert({ "_id" : ObjectId("5589929b887dc1fdb501cdba"), "_class" : "com.smartinnotec.aposoft.dao.domain.User", "title" : "DI.", ... "address" : { "_id" : null, ... "country" : "Österreich" }}) 

और अगर मैं db.User.find() के साथ इस प्रविष्टि आह्वान, की तुलना में मैं मिल निम्नलिखित:

{ "_id" : ObjectId("5589929b887dc1fdb501cdba"), "_class" : "com.smartinnotec.aposoft.dao.domain.User", "title" : "DI.", ... "address" : { "_id" : null, ... "country" : "�sterreich" } } 

विशेष पात्रों के साथ शब्द "�sterreich सही नहीं है।

क्या किसी को पता है कि मैं इस समस्या को हल करने के लिए मैंगोडब में क्या कर सकता हूं?

+1

क्या आप मोंगोडब का उपयोग कर रहे हैं? – Alex

+1

db.version() 3.0.7 – quma

+2

क्या आप इस परिणाम को मोंगो कंसोल से प्राप्त कर रहे हैं? – Rabea

उत्तर

4

लगता है कि आप एक स्ट्रिंग के अंदर एचटीएमएल कोड का उपयोग कर सकते तो

कोड:

आप & ouml उपयोग कर सकते हैं; डीबी में spl char को बचाने के लिए

{ "_id" : ObjectId("5589929b887dc1fdb501cdba"), "_class" : "com.smartinnotec.aposoft.dao.domain.User", "title" : "DI.", ... "address" : { "_id" : null, ... "country" : "Österreich" } } 

संदर्भ:

http://www.starr.net/is/type/htmlcodes.html

Replace multiple characters in a string in javascript

db.User.insert({ "_id" : ObjectId("5589929b887dc1fdb501cdba"), "_class" : "com.smartinnotec.aposoft.dao.domain.User", "title" : "DI.", ... "address" : { "_id" : null, ... "country" : "österreich" }}) 

और db.User.find() के साथ इस प्रविष्टि लागू पर, आप निम्न प्राप्त करेंगे

उम्मीद है कि यह मदद करता है।

7

JSON और BSON केवल एनकोड/डीकोड वैध UTF-8 तार, यदि आपका डेटा (शामिल इनपुट) UTF-8 आप इसे किसी भी JSON निर्भर व्यवस्था करने के लिए पारित करने से पहले इसे परिवर्तित करने के लिए, इस तरह की जरूरत नहीं है:

$string = iconv('UTF-8', 'UTF-8//IGNORE', $string); // or 
$string = iconv('UTF-8', 'UTF-8//TRANSLIT', $string); // or even 
$string = iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $string); // not sure how this behaves 

व्यक्तिगत रूप से मैं पहला विकल्प पसंद करता हूं, iconv() मैनुअल पेज देखें। अन्य विकल्प शामिल हैं:

mb_convert_encoding ("Österreich", "UTF-8", "ISO-8859-1");

  • utf8_encode(utf8_decode($string))

आप हमेशा अपने तार, UTF-8 एन्कोडेड हैं यह सुनिश्चित करना चाहिये भी उपयोगकर्ताओं द्वारा जमा किए हैं।

संबंधित मुद्दे