How to display Chinese characters in ASP using response.write?
<%
Response.CodePage=51936
Response.Charset="UTF-8"
Response.ContentType = "text/html"
Dim Msg
Msg="简"
%>
<%Response.Write Msg%>
Codepage 51936 is EUC-CN. Not UTF-8, which is 65001.
This long quiet question, still needs a verified solution!
I was successful in displaying Chinese and Korean characters from a UTF-8 encoded Classic ASP script.
All I did was simply add the meta charset tag in the head of the document, like so:
<%# Language=VBScript %>
<%
chinese="欢迎"
%>
<html>
<head>
<meta charset="UTF-8" />
...
</head>
<body>
<%= chinese %>
</body>
</html>
Related
I am trying to understand why this piece of code never prints the method request when run on tomcat 9:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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"></meta>
<title>Add Course</title>
</head>
<body>
<c:if test="${\"POST\".equalsIgnoreCase(pageContext.request.method) && pageContext.request.getParameter(\"submit\") != null}">
<%= request.getMethod() %>
</c:if>
<form method="post">
Name: <input type="text" name="name"> <br>
Credits : <input type="text" name="credits"> <br>
<button type="submit" name="submit">Add</button>
</form>
</body>
</html>
I don't have Tomcat 9 currently installed on my system, but it runs fine in Tomcat 8.5, and Jetty 9.4.17 printing "POST" whenever I post the form.
However, el language, despite resembling Java in many aspects and being able to call Java functions is NOT actually Java. You will encounter more success and consistency using it in a more idiomatic way. In your case, I'm pretty sure the following will work on any up-to-date JSP server:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!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"></meta>
<title>Add Course</title>
</head>
<body>
<c:if test="${'post' eq fn:toLowerCase(pageContext.request.method) and param.submit ne null}">
${pageContext.request.method}
</c:if>
<form method="post">
Name: <input type="text" name="name" /><br />
Credits: <input type="text" name="credits" /><br />
<button type="submit" name="submit">Add</button>
</form>
</body>
</html>
Using the fn taglib to compare strings in lower case
Using single quotes around strings to avoid escaping
Using el eq and ne operators for "equals" and "not equals"
Using el and boolean operator
Using el variable param to access request parameters
Using ${...} syntax to output values rather than scriptlets
I have a contact form at my website which support English / Arabic languages.I got a problem when my customers fill the form in Arabic language..I receive the email content "a lot of question marks" can't detect the Arabic language.
In html the meta tag for support arabic was included
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
for the form I write the form tag :
<form action="upload.php" method="post" enctype="multipart/form-data" accept-charset="utf-8" id="contactForm" name="sentMessage" novalidate="novalidate">
and in contactme.php this line was included
but still have the problem..need your help please.
I got email that shows in picture
Bundler update for the entire application caused a very specific issue with the <link> being returned from <%= stylesheet_link_tag 'application', media: 'all'%>
Instead of returning the usual <link rel="stylesheet" href="assets/application.css"> , it now returns <base href="/">
If I edit the HTML to manually add the <link>, the css shows up correctly which indicates that there is no compiler issue. Also, some answers that fixed somewhat similar problems did not work with this specific issue including (but not limited) to the following solutions:
# Enable the asset pipeline
config.assets.enabled = true
# Fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# Serve Static Assets.
config.serve_static_files = true
Also, switching ENVs and clearing cache with rake tmp:cache:clear and rake assets:clean did not had any effect on the issue...
To make things weirder, the ember stylesheet and script are working as expected:
<%= include_ember_stylesheet_tags :frontend %>
<%= include_ember_script_tags :frontend %>
<link rel="stylesheet" href="assets/frontend.css">
<script src="assets/frontend.js"></script>
Issue is possibly related to one of this gems:
Rails (4.2.5)
Sprockets (3.5.2)
You can view the complete Gemfile.lock or the entire Source Code on Github.
Another possible root cause is a new route configuration where somehow mount_ember_app :frontend, to: "/" relates to the lack of <link> being returned and <base href="/"> being returned instead since both maps to "/". However, I could certainly be wrong about it...
This is all the information that I was able to gather since I could not see any useful information on the logs including the browser's output.
This problem showed up after several upgrades around, especially after mount_ember_app was created. The way to fix it is to have a similar structure to the following:
Ember-Cli-Rails Initializer
EmberCLI.configure do |config|
config.app :frontend, build_timeout: 30
end
Routes.rb
mount_ember_app :frontend, to: "/", controller: "application"
App/views/application/index.html.erb
<%= render_ember_app :frontend do |head| %>
<% head.append do %>
<%# Rails Asset Pipeline%>
<%= stylesheet_link_tag 'application', media: 'all'%>
<%= javascript_include_tag 'application' %>
<%# Ember-cli-rails Pipeline - Frontend Stylesheet is not used.%>
<%= include_ember_script_tags :frontend %>
<% include_ember_stylesheet_tags :frontend %>
<%# META Stuff %>
<%= csrf_meta_tag %>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<% end %>
<% end %>
Frontend/App/index.html
<!DOCTYPE html>
<html>
<head>
<title>Frontend</title>
{{content-for 'head'}}
{{content-for 'head-footer'}}
</head>
<body>
{{content-for 'body'}}
{{content-for 'body-footer'}}
<%= render partial: "layouts/shared/analytics" %>
</body>
</html>
This will solve most, if not all assets issues. <base href="/"> apparently is normal as I now believe that it simply refers to the mount point for the Frontend.
I also had issues with #mixins after most of the SCSS came back to life, but later I found out that they were tied to a totally different issue, and therefore will not be discussed in this answer.
I have two date textboxes in my ASP.Net application and these textboxes are using MaskEditExtender so that only date can be entered in them. These textboxes are actually from and to textboxes to enter a date range.
The issue is that in IE 11 the user is not able to copy-paste date from one text box to other using Ctrl+C and Ctrl+V.
The user is able to paste the date by right clicking and selecting copy paste but in this also the date does not get properly formatted in the second textbox. In IE8 and lower browsers it worked fine.
Sample code used:-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1"
Mask="99/99/9999" MaskType="Date" ClipboardEnabled="true"/>
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender2" runat="server" TargetControlID="TextBox2"
Mask="99/99/9999" MaskType="Date" ClipboardEnabled="true"/>
</div>
</form>
</body>
</html>
Please suggest.
Yes, there is a bug that was fixed recently, but this fix is not published at the moment.
You can see changes here or wait for new ACT release.
I have a problem when using special characters in meta and alt text in Umbraco.
I am testing with Meta description and Alt text like this: Test test æøå
And it generates this output:
<meta name="description" content="Test test æøå">
<img src="#" alt="Test test æøå" />
If I insert the same text in title tags and normal content, then the output is just perfect.
The code that is generating the meta and title tags looks like this:
<!DOCTYPE html>
<html lang="da">
<head>
<meta charset="utf-8">
<meta name="description" content="#Umbraco.Field("pageDescription")">
<title>#Umbraco.Field("pageTitle")</title>
</head>
The files are saved as utf-8 using Notepad++.
If I insert æøå directly in the HTML, then it shows æøå without any problems.
I have also tried this:
<p>#Umbraco.Field("pageDescription")</p>
And then it shows "æøå" correctly.
Does anybody know what I am doing wrong?
Thanks in advance!
// René
Looks like this is a "feature" of Razor that it will always HTML encode attributes. See: Razor - #Html.Raw() still encoding & in meta tag attributes
So to work around this, you can do the following:
<meta name="description" #Html.Raw("content=\""+ #Umbraco.Field("pageDescription") + "\"") />
<title>#{ var title = new HtmlString(Umbraco.Field("pageTitle").ToString());}#title</title>
It's not pretty, but it works.