Hi Vinod,

Can you try IOUtils and set UTF-8 encoding? I used it in one of my project
and works fine.

HttpResponse response = client.execute(getReq);// execute get request
response.setHeader("Content-Type", "text/html; charset=utf-8");
result = IOUtils.toString(response.getEntity().getContent(), "UTF-8");

Regards,
Indy

On Wed, Oct 5, 2016 at 8:18 PM, <[email protected]> wrote:

> Hi Eric,
>
> Thanks for Responding.
>
> We are calling MarkLogic Custom services using apache commons http client
> to get the data. We are getting the response as UTF-8 encoded only.
> final HttpResponse response = httpClientExecutor.execute(request,
>                                   globalProperties.getProperty(
> MARKLOGIC_USERNAME),
>                                   globalProperties.getProperty(
> MARKLOGIC_PASSWORD));
>
>
> response.getEntity() is still in UTF-8  encoding only.
>
> We are converting response entity  to string and creating JSON object
>
> final String strEntiry = EntityUtils.toString(response.getEntity());
>
> When we debug ,At this point it self we are not receiving the special
> characters properly and getting some dirty characters in place of special
> characters.
>
> return new JSONObject(strEntiry);
>
> And we tried reading strEntiry as UTF-8 encoded explicitly like below
>
> final String strEntiry = EntityUtils.toString(response.
> getEntity(),"UTF-8");
>
> but the result is same.
>
>
> Thanks,
> Vinod.
>
> -----Original Message-----
> From: [email protected] [mailto:general-bounces@
> developer.marklogic.com] On Behalf Of general-request@developer.
> marklogic.com
> Sent: Wednesday, October 05, 2016 6:20 PM
> To: [email protected]
> Subject: General Digest, Vol 148, Issue 7
>
> Send General mailing list submissions to
>         [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://developer.marklogic.com/mailman/listinfo/general
> or, via email, send a message with subject or body 'help' to
>         [email protected]
>
> You can reach the person managing the list at
>         [email protected]
>
> When replying, please edit your Subject line so it is more specific than
> "Re: Contents of General digest..."
>
>
> Today's Topics:
>
>    1. Re: Issue with special charecters in      MarkLogic (Kapoor, Pragya)
>    2. Re: Issue with special charecters in      MarkLogic (Erik Hennum)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 5 Oct 2016 11:06:51 +0000
> From: "Kapoor, Pragya" <[email protected]>
> Subject: Re: [MarkLogic Dev General] Issue with special charecters in
>         MarkLogic
> To: "[email protected]"
>         <[email protected]>
> Message-ID:
>         <HK2PR02MB1364317FEDEF56E787A424CEEAC40@HK2PR02MB1364.
> apcprd02.prod.outlook.com>
>
> Content-Type: text/plain; charset="us-ascii"
>
> You can try using  xdmp:url-decode()
>
>
> Example:
>
> let $write := ""write &#x01d622;(&#x01d639;)/&#x01d623;(&#x01d639;))"
> return xdmp:url-decode($write)
>
>
> This will give the output as " write ?(?)/?(?)
>
>
> Thanks
>
> Pragya
>
>
> ________________________________
> From: [email protected] <general-bounces@developer.
> marklogic.com> on behalf of [email protected] <
> [email protected]>
> Sent: Wednesday, October 5, 2016 3:53:16 PM
> To: [email protected]
> Subject: [MarkLogic Dev General] Issue with special charecters in MarkLogic
>
> Hi All,
>
> We are facing an issue with special characters involved in mathematical
> expressions such as " write ?(?)/?(?) in the form " which has  italic
> characters (?(?)/?(?)). In MarkLogic these are stored as UTF-8 encoded
> values as "write &#x01d622;(&#x01d639;)/&#x01d623;(&#x01d639;) in the
> form". In Java application When we are retrieving data from MarkLogic DB
> ,these special characters are being received  as " write ?c(?^1)/??(?^1) in
> the form" .  These are being corrupted by the time we received them in Java
> layer.
>
> We tried many options from Java side to receive content as UTF-8 encoded,
> but did not resolved the issue. Can anyone please suggest a way to  resolve
> this kind of issues from MarkLogic side.
>
>
> Thanks,
> Vinod.
>
>
>
>
>
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful. Where permitted by
> applicable law, this e-mail and other e-mail communications sent to and
> from Cognizant e-mail addresses may be monitored.
> "This e-mail and any attachments transmitted with it are for the sole use
> of the intended recipient(s) and may contain confidential , proprietary or
> privileged information. If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all copies of the original
> message. Any unauthorized review, use, disclosure, dissemination,
> forwarding, printing or copying of this e-mail or any action taken in
> reliance on this e-mail is strictly prohibited and may be unlawful."
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://developer.marklogic.com/pipermail/general/
> attachments/20161005/672a0faf/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Wed, 5 Oct 2016 12:50:25 +0000
> From: Erik Hennum <[email protected]>
> Subject: Re: [MarkLogic Dev General] Issue with special charecters in
>         MarkLogic
> To: MarkLogic Developer Discussion <[email protected]>
> Message-ID:
>         <DFDF2FD50BF5AA42ADAF93FF2E3CA1850BD35D19@EXCHG10-BE01.
> marklogic.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi, Vinod:
>
> If you read the character stream as UTF-8 in Java, you shouldn't need to
> do anything special on either the client or server.
>
> Are you using the MarkLogic Java Client API?  The Java API knows the
> server encodes as UTF-8 and defaults to reading as UTF-8.
>
> The only other question that occurs to me is whether the code that's
> writing the content might be double encoding.
>
>
> Hoping that helps,
>
>
> Erik Hennum
>
>
> ________________________________
> From: [email protected] [general-bounces@developer.
> marklogic.com] on behalf of [email protected] [
> [email protected]]
> Sent: Wednesday, October 05, 2016 3:23 AM
> To: [email protected]
> Subject: [MarkLogic Dev General] Issue with special charecters in MarkLogic
>
> Hi All,
>
> We are facing an issue with special characters involved in mathematical
> expressions such as ? write ?(?)/?(?) in the form ? which has  italic
> characters (?(?)/?(?)). In MarkLogic these are stored as UTF-8 encoded
> values as ?write &#x01d622;(&#x01d639;)/&#x01d623;(&#x01d639;) in the
> form?. In Java application When we are retrieving data from MarkLogic DB
> ,these special characters are being received  as ? write ??(??)/??(??) in
> the form? .  These are being corrupted by the time we received them in Java
> layer.
>
> We tried many options from Java side to receive content as UTF-8 encoded,
> but did not resolved the issue. Can anyone please suggest a way to  resolve
> this kind of issues from MarkLogic side.
>
>
> Thanks,
> Vinod.
>
>
>
>
>
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful. Where permitted by
> applicable law, this e-mail and other e-mail communications sent to and
> from Cognizant e-mail addresses may be monitored.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://developer.marklogic.com/pipermail/general/
> attachments/20161005/44e370e6/attachment.html
>
> ------------------------------
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
> End of General Digest, Vol 148, Issue 7
> ***************************************
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful. Where permitted by
> applicable law, this e-mail and other e-mail communications sent to and
> from Cognizant e-mail addresses may be monitored.
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to