Hi Andy, thanks for the reply,
good luck with that!! seems really nasty to me, first of all just
because I think that you have to guess the charset of the response
just to override it... At the minute I'm using ICU and in openBD all
strings are detected as ISO-8559-1 It does not really matter if I set
the encoding to UTF-8 or use the cfprocessing directive like this
<cfscript> SetEncoding("form","utf-8"); SetEncoding("url","utf-8");</
cfscript>
<cfprocessingdirective pageencoding="utf-8">
here is the code:
private function icuMatch(text)
{
var icuDetector = createObject('java',
'com.ibm.icu.text.CharsetDetector').init();
icuDetector.setText(createObject('java',
'java.io.StringBufferInputStream').init(text));
return icuDetector.detect();
}
thats why in my example when Im passing the ad to elasticsearch the
encoding shows "encoding":"ISO-8859-1","language":"es","tokens":
when in reality is being posted with UTF-8.
At least with spanish, german, italian and so on is working but with
languages like russian or chinese is creating a complete mess creating
double encoded strings???
I'm very new to CF and openBD but In railo everything was always
converted into \u characters...
On 3 abr, 13:00, Andy Wu <[email protected]> wrote:
> Hi David,
>
> We should really be passing the charset with the request. I'll get that
> fixed soon as I have some other changes to make in that area.
>
> It's interesting though, reading the latest ACF docs, that it sounds
> like the CHARSET attribute is supposed to serve dual purposes - setting
> the character encoding of the request and providing the ability to
> override that of the response.
>
> Andy
>
> On 03/04/2012 08:57, David G Ortega wrote:
>
>
>
>
>
>
>
> > Hi guys,
>
> > finally viewing the data with a proxy seemed that the data was
> > properly encoded in UTF-8 but especifying the charset into the cfhttp
> > tag didn't work. Finally I had the idea of sending the content type
> > with the charset especification and it worked.
>
> > <cfhttp method='post' url='http://localhost:9200/chingame/ads/
> > #ad.id#' result='httpRequest' timeout='20' charset="utf-8">
> > <cfhttpparam type="header" name="Content-Type" value="application/
> > json; charset=utf-8" />
> > <cfhttpparam type='body', value='#ad.json#'>
> > </cfhttp>
>
> > On 2 abr, 23:41, David G Ortega<[email protected]> wrote:
> >> sorry Matthew I posted it wrong!
>
> >> Here it is
>
> >> <cfscript>
> >> ad = {};
> >> ad.title = "Joe's Caf & Bar";
> >> ad.desc = ' ';
> >> ad.address = '29600 Marbella Malaga';
>
> >> ad.id = hash(serializeJSON( ad.title ), 'MD5');
> >> ad.date = requestKey('date', dateFormat(now(),
> >> 'yyyy-mm-dd')& 'T'
> >> & timeFormat(now(), 'HH:mm:ss'));
>
> >> ad.json = serializeJSON(ad);
> >> </cfscript>
>
> >> <cfhttp method='post' url='http://localhost:9200/chingame/ads/
> >> #ad.id#' result='httpRequest' timeout='20' charset="utf-8">
> >> <cfhttpparam type='body', value='#ad.json#'>
> >> </cfhttp>
>
> >> <cfscript>
> >> writeDump(httpRequest);
> >> </cfscript>
>
> >> On 2 abr, 23:38, David G Ortega<[email protected]> wrote:
>
> >>> Sure Matthew,
> >>> this is the code reduced to the bare minimum
> >>> <cfscript>
> >>> ad = {};
> >>> ad.title = "Joe's Caf & Bar";
> >>> ad.desc = ' ';
> >>> ad.address = '29600 Marbella Malaga';
> >>> ad.id = hash(serializeJSON( ad.title ), 'MD5');
> >>> ad.date = dateFormat(now(), 'yyyy-mm-dd')& 'T'&
> >>> timeFormat(now(),
> >>> 'HH:mm:ss');
> >>> ad.json = serializeJSON(ad);
> >>> <cfhttp method='post' url='http://localhost:9200/chingame/ads/
> >>> #ad.id#' result='httpRequest' timeout='20' charset="utf-8">
> >>> <cfhttpparam type='body', value='#ad.json#'>
> >>> </cfhttp>
> >>> <cfscript>
> >>> writeDump(httpRequest);
> >>> </cfscript>
> >>> </cfscript>
> >>> serializeJSON seems to not being encoding to UTF8
> >>> On 2 abr, 23:28, Matthew Woodward<[email protected]> wrote:
> >>>> On Mon, Apr 2, 2012 at 2:25 PM, David G
> >>>> Ortega<[email protected]>wrote:
> >>>>> for similar post Railo is sending this
> >>>>> {"LNKSRC":"","ID":"BF2A25AF8A4568D899AEE7806BD74904","TITLE":"Joe's Caf
> >>>>> \u00e9& Bar","DESC":"\u00f1 \u20ac \u00ed","LNKHREF":"\/
> >>>>> BF2A25AF8A4568D899AEE7806BD74904","ADDRESS":"<a>29600 Marbella Malaga<
> >>>>> \/a>","IMAGES":[],"DATE":"2012-04-02T23:21:33"}
> >>>>> which is working...
> >>>> It would be helpful to see the code around what you're doing as opposed
> >>>> to
> >>>> just the resultant json string.
> >>>> --
> >>>> Matthew Woodward
> >>>> [email protected]http://blog.mattwoodward.com
> >>>> identi.ca / Twitter: @mpwoodward
> >>>> Please do not send me proprietary file formats such as Word, PowerPoint,
> >>>> etc. as
> >>>> attachments.http://www.gnu.org/philosophy/no-word-attachments.html
--
online documentation: http://openbd.org/manual/
google+ hints/tips: https://plus.google.com/115990347459711259462
http://groups.google.com/group/openbd?hl=en