extjs 4.2 - entity encoding with backslash e.g. '\1014' - extjs

The value "\1014" is coming from my database and I want to display it in an ExtJS Panel.
The problem is, it gets processed as an entity value, and "A4" is displayed instead
I don't want to have to do entity encoding on the back end.
I tried
Ext.util.Format.htmlEncode('\1014')
But this also returns "A4"
What is the correct way to encode such values on the front-end for display?

This has nothing to do with ExtJS. This is a builtin feature of JavaScript and JSON. If you want to send the non-literal \101 as JSON to the frontend, you have to escape the backslash correctly to the specs in the backend:
{"success":true,"data":{"test":"\\101","id":"extModel2-1"}}
If you don't escape the backslash, it will be converted to the appropriate literal immediately when it hits the frontend and is then indistinguishable from the letter A, so this is not revertible on the frontend.
Relevant fiddle
Relevant older answer

You can parse data using JSON.parse(response.reponseText) instead of Ext.decode

Related

Logic app turn the binary to bad character

I created a logic app which gets the data from restapi. The content type of data is Application/protobuf(protobuf is a binary data made by google https://developers.google.com/protocol-buffers/docs/tutorials) I know that LA uses base64 encoding so it changes the data to base64 encoding. As the data to be deserialised via protoc complier so it needed binary format. So i store this data into a variable and trying to paas this further processing. But unfortunately the data stores in variable changes into boxes and ? So protoc compiler fails to deserialised the same.
I tried base64tobinary and http() as per suggestion mentioned section "other content type" on microsoft https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-content-type#applicationxml-and-applica...
But it did not work. Can anybody help on this?
I tried reproducing the issue and found that the rest API body which we are receiving will be transformed back to string when we use string() i.e.. string(triggerBody()) dynamic expression.
Later, I convert to binary by using the dynamic expression 'binary', i.e. 'binary(outputs('Compose')', which will return a 'application/octet-stream' result. When I tried to convert back to a string, everything worked great for me.
Here is the flow of my logic app
and here is the output
I have changed the way of using. Instead of streaming, I am storing the data into file and processing further.

Solrj ClientUtils toQueryString escapes facet.pivot field comma

The toQueryString method inside Solrj's ClientUtils class is called when the http request is formed internally. But in this process, it also encodes the commas (,) that need to be sent in the facet.pivot field.
eg . facet.pivot=A1,A2 gets sent as facet.pivot=A1%2CA2
Because of this the query returns no result.
Please suggest a mechanism to report this or any work around for the same.
Your question is about escaping/encoding the query for a solr request.
In current version of solr the toQueryString method is moved to SolrParams. But never the less "%2C" ist correct for "," in utf-8.
So most likely you have a problem on server side with unencoding the params.
Try solr in current version, because in this case you don't need to config the servlet container properly: it is now part of solr.
btw: take a look to sub-facets instead of pivot-faceting: http://yonik.com/solr-subfacets/

Extjs 4.0.7 grid utf8 encoding issue

I have a grid and arrived data (Ext Direct), for example (firebug):
But in the grid you see:
If I click double to show full data, in the title of window, this data does not have trouble (come from the record):
The other columns render datas without problem. Do you have any idea to fix it?
I also live in a country where we need the accented characters (Slovakia) and I went through all possible encodings and troubles with localization. After all, UTF-8 is the real solvent. Since I use UTF-8 in database, in apache (Ajax) headers and on the HTML on the page I have no problmes.
Therefore, check if somewhere in the route the encoding does not change, check if UTF-8 is really sent from the server, check all headers, etc. The only problem that UTF-8 ceased to be used somewhere on the route.

Using PreAnalyzedField in Solr 4

I am trying to index fields using Solr, in which I already have a TokenStream. I dont want Solr to have any analysis - Its already made. As I understood, I could get this exact functionality using Solr's PreAnalyzedField.
The problem is that I cannot find any good resource to help me understand the flow:
I needto define the field in the schema.xml file as PreAnalyzedField, and the tokenstream should be parsed using the parse method of the parser implementation - but how to I actually feed the field with my tokeStream? how \ when exactly is it sent to the toFormattedString method???
I think PreAnalyzedField is a bleeding edge of Solr as of 4.0/4.1. The main documentation is on the Wiki and basically explains the two parser types. The default is JSON, I am not sure how to get the other type to work.
Once you have that type defined, you just supply fully-tokenized content in the JSON format as described as that field's value. When that hits the parser, it will convert it to the Token stream. The same way a number gets parsed from a string representation into a real numeric representation. Try feeding an unparsable value and you will see the full call stack in the exception stacktrace.
The problem is how to query it. My own discussion on the mailing list did not get very far.

Saving new Lines in database and Json

I have this problem:
I have an HTML textarea which is filled by the user. (And he can press The enter button to go on a new line).
Then I take The value of The textarea using the command:
document.getElementById("textareaCommento")
And I pass The value to the servlet using an XmlHttpRequest.
In The servlet I save this value in a database.
Since this point I have no problems...
Then, in another part I want to get The values from The database. Using a servlet I make this query
Select * from comments
And I transform the results in json. Here I have The problem... The newline character makes my JSON string invalid. For example:
"Comment":"hello
Word"
How can I do?
Thanks in advance!
You have to replace the \n character from database to something like <br/>
For the replace see replace \n and \r\n with <br /> in java
this CSS worked for me,
white-space: pre-line;
You should be able to url encode your values so hello world would actually become "hello%20world", to do it in java see here:
Encoding URL query parameters in Java
To do it in javascript see here:
Encode URL in JavaScript?

Resources