I'm developing a tool using JSF 1.1 and I'm having this problem :
I have a String in my backing bean which is printed as:
./src.cpp: In function ‘int main()’:
./src.cpp:4: error: ‘dsdada’ was not declared in this scope
on a txt file.
But when I put it on a h:inputTextArea, it goes like this:
./src.cpp: In function ‘int main()’:
./src.cpp:4: error: ‘dsdada’ was not declared in this scope
-
<%# page contentType="text/html;charset=UTF-8" %>
and this
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
But it didn't work either.
can somebody tell me how to fix this. Thanks
/* String[0] as stdout, String[1] as stderr */
String[] results = sshBO.execCommand(cmd, timeout);
/* Done with SSH things */
sshBO.closeSession();
/* Bring the output and err to the presentation */
msg = results[1]+results[0];
FileServices.saveStringToFile("F:/myoutput.txt", msg);
msg = new String(msg.getBytes("UTF8"), "UTF8"); /* makes no difference */
on the JSP pages :
<%# page contentType="text/html;charset=UTF-8" %>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%# taglib uri="http://sakaiproject.org/jsf/sakai" prefix="sakai" %>
<f:view >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
...
<h:inputTextarea disabled="true" value="#{SSH.msg}" styleClass="myTextArea" />
The character ‘ exist in Unicode of the bytes 0xE2 0x80 0x98. When you use the CP1252 (Windows default) encoding to encode those bytes, you get ‘.
You need to explicitly set the pageEncoding to UTF-8.
<%# page pageEncoding="UTF-8" %>
This way it will print the characters using UTF-8 and implicitly set the Content-Type header right.
In order to determine the source of your transcoding bug, inspect the data after each transcoding operation. Use a tool like this one to determine what the values should be.
For example, Java strings are being transcoded from UTF-16 (the encoding of Java strings) to UTF-8 by your JSP writer. The other transcoding operation looks like reading program output from the native system.
/* String[0] as stdout, String[1] as stderr */
String[] results = sshBO.execCommand(cmd, timeout);
For example, you can print the hex values of your strings using code like this:
for (char ch : msg.toCharArray())
System.out.format("%04x ", (int) ch);
The code point ‘ should print as 2018. Your file writing code may share a similar bug to the code that reads input, misleading you about the source of the problem.
msg = new String(msg.getBytes("UTF8"), "UTF8"); /* makes no difference */
This makes no difference because it takes UTF-16 data, transcodes it to UTF-8, then transcodes it back to UTF-16. But aside from that, if your string is corrupt, it's already too late. You're fixing the bug in the wrong place.
Related
IN razor format, we can use #Html.Raw to add meta-tags from string, for example, in controller we can write;
Model header = new Model();
header = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
in Layout Page we can add the above string in <Head> section as
#Html.Raw(Model.header)
How can I do the same in Index.Html in Angular 8 (not using razor). The string "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"
is retrieved from DB and need to be appended to "<Head>" section in index.html. I do not have control over what will be provided from DB. But whatever will be the value it will be <Head> or section related, and may also include <scripts>.
Thanks
Found the answer, for someone who is also looking for this solution:
let fragment = document.createRange().createContextualFragment("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
document.head.append(fragment);
I am trying to convert a asciidoc file containing math expression to html using AsciidoctorJ, but have been unsuccessful so far.
This is the math.asciidoc that i am trying to convert.
= My Diabolical Mathmatical Opus
Jamie Moriarty
sample1
asciimath:[sqrt(4) = 2]
stem:[sqrt(4) = 2]
I am using the below configuration in Asciidoc
Attributes attributes = AttributesBuilder.attributes()
.math("asciimath")
.get();
Options options = OptionsBuilder.options()
.attributes(attributes)
.docType("article")
.safe(SafeMode.SERVER)
.backend("html5")
.get();
asciidoctor.convert(asciiDoc, options);
The output always shows something like this:
sample1
\$sqrt(4) = 2\$
\$sqrt(4) = 2\$
In the above generated HTML output, how do we render the mathematical equations?
Asciidoctor support asciimath and latexmath syntax and the output produced by asciimath can be rendered on browser using http://asciimath.org js library (other asciimath libraries can also be used).
Asciidoctorj uses \$ as the delimiter for asciimath markup, so we need to configure MathJax using the following configuration:
<html>
<head>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
asciimath2jax: {
delimiters: [['\\$','\\$'], ['`','`']]
}
});
</script>
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
...
</head>
//rest of html
</html>
After we include the above code snippet in <head> section of html, asciimath rendering shall work fine.
We can refer to this section of Asciidoctor documents for activating support of asciimath inside asciidocs: https://asciidoctor.org/docs/user-manual/#activating-stem-support
i used mathjax in HTML page , it works. but a problem related to fontsize exist.
<html>
<head>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<title> mathsjax</title>
</head>
<body>
\(x={72^2-{\sqrt{53^2}}\over 25}\)
$$x={72^2-{\sqrt{53^2}}\over 25}$$
</body>
</html>
why in the first syntax[(x={72^2-{\sqrt{53^2}}\over 25})] , fontsize is very small. and what to do to increase its size.
In addition, what is the difference between the two syntax's
\(x={72^2-{\sqrt{53^2}}\over 25}\) .........1
$$x={72^2-{\sqrt{53^2}}\over 25}$$ .........2
You should use \( for inline math, and \[ as equivalent of $$.
<html>
<head>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<title> mathsjax</title>
</head>
<body>
This is part of the line: \(x={72^2-{\sqrt{53^2}}\over 25}\). Those are not:
\[x={72^2-{\sqrt{53^2}}\over 25}\]
$$x={72^2-{\sqrt{53^2}}\over 25}$$
</body>
</html>
EDIT
If it isn't enough you can also add \large or \huge.
In his comments OP says he is using HTML ckeditor, I suppose with the Mathematical Formulas widget. You can locate the demo of that widget in page linked and modify its source adding the following code:
<p><span class="math-tex">\( x={72^2-{\sqrt{53^2}}\over 25}\)</span></p>
<p><span class="math-tex">\[ x={72^2-{\sqrt{53^2}}\over 25}\]</span></p>
<p><span class="math-tex">\[ \large { x={72^2-{\sqrt{53^2}}\over 25} } \]</span></p>
<p><span class="math-tex">\[ \huge { x={72^2-{\sqrt{53^2}}\over 25} } \]</span></p>
This should be the result:
You can use {\displaystyle{...}} to force an expression or subexpression to use the sizes and spacing that would be used for a displayed equation. For fractions in particular, if you have the AMSmath extension loaded, you can use \dfrac{}{} in place of \frac{}{} to get a fraction in display style.
I have some troubles including AlloyUI in my Liferay Portlet.
Following this article, I have generated the following jsp:
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<input type="text" id="some-input" />
<span id="counter"></span> character(s) remaining
<aui:script>
YUI().use(
'aui-char-counter',
function(Y) {
new Y.CharCounter(
{
counter: '#counter',
input: '#some-input',
maxLength: 10
}
);
}
);
</aui:script>
But the rendered page looks like this:
I made sure that the taglib is correctly defined in the web.xml:
<taglib>
<taglib-uri>http://liferay.com/tld/aui</taglib-uri>
<taglib-location>/WEB-INF/tld/aui.tld</taglib-location>
</taglib>
AUI does work, when I include it in the jsp as follows:
<script src="http://cdn.alloyui.com/2.0.0/aui/aui-min.js"></script>
<link href="http://cdn.alloyui.com/2.0.0/aui/aui-min.js" rel="stylesheet"></link>
<input type="text" id="some-input" />
<span id="counter"></span> character(s) remaining
<script>
YUI().use(
'aui-char-counter',
function(Y) {
new Y.CharCounter(
{
counter: '#counter',
input: '#some-input',
maxLength: 10
}
);
}
);
</script>
I'm using Liferay 6.1.20 EE GA2
Liferay uses alloy-ui (also referred to asAUI) library developed on top of Yahoo UI (also referred to as yui) library.
The instance terms for both these libraries are different i.e. AUI for Alloy-UI and YUI for the other.
Replacing these terms in your code will resolve your issue i.e. have AUI instead of YUI.
The seed file declaration is all you need to access AlloyUI for this char counter code.
<script src="http://cdn.alloyui.com/2.0.0/aui/aui-min.js"></script>
You shouldn't need the taglib reference in your web.xml. In fact, you're inhibiting access to the seed file. The taglib you're referencing may be inconsistent with the version of AlloyUI that is expected.
Also, accessing YUI's CharCounter is fine. See the API example at http://alloyui.com/api/classes/A.CharCounter.html.
I would like to listen for all io request in all my web pages, however, when I used the syntax below, I can ONLY listen for the io with the yui instance.
Y.on('io:success', myCallBack);
How can I write a custom method/event or something else to achieve this?
My question is actually the same as below URL:
http://yuilibrary.com/forum/viewtopic.php?p=26009
I googled for a while but did not find a practical answer for this, any help will be appreciated, thanks.
Try
(Y.io._map['io:0'] || new Y.IO()).publish({
'io:success': { broadcast: 2 },
'io:complete': { broadcast: 2 },
etc.
});
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>io.jsp</title>
<script src="/spring-test/scripts/yui_3.5.1/build/yui/yui-min.js"></script>
</head>
<body>
test
<script>
YUI().use("io-base", function(Y){
function onSuccess(transactionid,response,arguments){
alert('start!');
}
Y.Global.on('io:start',onSuccess);
});
Y1 = YUI().use("io-base", "node", function(Y1){
Y1.publish('io:start',{broadcast : 2});
Y1.io("http://www.yahoo.com.hk");
});
</script>
</body>
Finally I got one example , however it works only on FF, Chrome but fail in IE:
Please suggest if there is any improvement, thanks.