MongoDB SpiderMonkey doesn't understand UTF-8

喜你入骨 提交于 2019-12-18 15:52:39

问题


If I add non-ASCII characters to MongoDB database then all db.find() fail telling "non ascii character detected".

It's problem of SpiderMonkey, I have to rebuild it with UTF-8 support. I've tried to do it like in http://www.mongodb.org/display/DOCS/Building+Spider+Monkey

but it doesn't work (SpiderMonkey is not installed after I've completed all steps).

I've got Ubuntu 11.04. Does anybody have instruction how to make it work there?

Working instruction how to make work MongoDB with Google V8 can also help.


回答1:


I'm using MongoDB on Ubuntu Server 11.04, installed it after making fresh OS install using this instruction: http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages Everything is working fine out of the box. Is it critical for you to build MongoDB from scratch?




回答2:


Using the 10gen-published packages works fine, but if you actually want to compile SpiderMonkey from source with UFT-8 support:

curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvzf js185-1.0.0.tar.gz
cd js-1.8.5/js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
export CXXFLAGS="-DJS_C_STRINGS_ARE_UTF8"

And then follow the instructions from https://developer.mozilla.org/En/SpiderMonkey/Build_Documentation

autoconf-2.13
./configure
make
make install
cp js /usr/local/bin/

This will install into /usr/local/lib, however the mongodb package looks for it in /usr/lib (where the spidermonkey package is installed). So, we link all files installed to /usr/local /lib from /usr/lib

ln -s /usr/local/lib/libmozjs185.so /usr/lib/libmozjs185.so
ln -s /usr/local/lib/libmozjs185.so.1.0 /usr/lib/libmozjs185.so.1.0
ln -s /usr/local/lib/libmozjs185.so.1.0.0 /usr/lib/libmozjs185.so.1.0.0
ln -s /usr/local/lib/libmozjs185-1.0.a /usr/lib/libmozjs185-1.0.a

Of course you could just move them into /usr/lib instead of symlinking, but I wanted to keep the utf-enabled libs away from the default location, to prevent conflicts with the default spidermonkey package. Without the libmozjs package installed, apt complains that dependencies for mongodb are not satisfied, so I've left it installed.

Keep in mind that if the spidermonkey package gets upgraded, it can overwrite the symlinks to our new libs (or the libs themselves if you've moved them to /usr/local/lib). The ideal solution would be to build your own package to solve dependency issues for good.



来源:https://stackoverflow.com/questions/6268132/mongodb-spidermonkey-doesnt-understand-utf-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!