Retrieving a MongoDB Document with accents

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
javmirval
Posts: 10
Joined: Sun Feb 09, 2014 5:55 am

Retrieving a MongoDB Document with accents

Post by javmirval » Fri Sep 05, 2014 3:50 am

When I enter "Se cambiarán los bornes" (please note the accent), in a LiveCode field, the text is properly shown, writting it to a Mongo collection also works fine, the field is saved OK in the document, I can see it using the Shell, but when retrieving the document back to LiveCode, the field receiving the field shows: "Se cambiarían los bornes". Trying to find the reason I found that the encoding of field "resul" is Native. Can you help finding the way to make this strings show the right characters?

The code retrieving the document from the database is:

on mouseUp
local theMongo, theDB, dbText, theCole, thePreg, theQuerry
put empty into field resul
put "C:\mongodb\bin\mongo.exe localhost:27017/" into theMongo
put "BatGar" into theDB
put "BatRegis"into theCole
put "'" & field F1 & "'" into toFind
put "{"& quote & "_id" & quote & ":" & toFind & "}" into thePreg
put "; printjson(db.getLastError())" into dbErr
put ".find(" & thePreg & ");"into theQuerry
put "var c=db."& theCole & theQuerry into dbText
put " while(c.hasNext())" after dbText
put " printjson(c.next())" after dbText
put dbErr after dbText
put theMongo & theDB && "--eval" && quote & dbText & quote into dbText1
put shell ( quote &dbText1 & quote) into dbResultado
put the number of lines of dbResultado into nro
put line 3 to (nro - 1) of dbResultado into field resul
if field resul is empty then
Answer warning "El Documento NO ha sido encontrado. El sistema no tiene registrada una Batería con el ID: " & field F1 with OK
else
Answer warning "El Documento ha sido encontrado, ID: " & field F1 with OK
end if

Post Reply

Return to “Databases”