【发布时间】:2014-06-30 22:58:39
【问题描述】:
我正在尝试显示存储在数据库中的字符,它是 unicode 字符 \u0096。由于奇怪的 windows-vs-web-browser 事情,这是 unicode 标准中的控制字符,但网页会将其显示为 En Dash。请参阅@AlanMoore 在Some UTF-8 characters do not show up on browser 上的回答。
我有以下 jsp 文件。我想将 \u0096 字符显示为 En Dash(其他前端解决方案可以完成的壮举)。
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page session="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!doctype html>
<html>
<c:set var="control" scope="request" value= "b"/>
<c:set var="endash" scope="request" value="a"/>
<% request.setAttribute("control", "\u0096");%>
<% request.setAttribute("endash", "\u2013");%>
Match? 0096: <c:out value="${control}"/> 2013: <c:out value="${endash}"/>
我得到的输出是
Match? 0096: 2013: –
我想要的是
Match? 0096: – 2013: –
【问题讨论】:
标签: jsp unicode character-encoding