4

我想知道在我的代码中使用奇怪的字符是否是个坏主意。我最近尝试使用它们创建小点来指示您正在使用哪张幻灯片并轻松更改幻灯片:

在此处输入图像描述

这些类型的字符有很多,在许多情况下,它们似乎可以用来代替图标/图像,它们具有样式和可缩放性,并且屏幕阅读器能够理解它们。

但是,我没有看到任何人这样做,而且我觉得这是一个坏主意,我无法确定为什么。我想这似乎太容易了。有人可以告诉我为什么这样可以或不可以吗?以下是我正在谈论的角色的更多示例:

↖ ↗ ↙ ↘ ㊣ ◎ ○ ● ⊕ ⊙ ○ △ ▲ ☆ ★ ◇ ◆■ □ ▽ ▼ § ¥ 〒 ¢ £ ※ ♀ ♂ &⁂ ℡ ↂ░ ▣ ▤ ▥ ▦ ▧ ✐✌✍✡✓✀✌✍✡ ♡ ☜ ☞ ☎ ☏ ⊙ ◎ ☺ ☻ ► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕ ♥ ♡ ▪ ▫ ☼ ♦ ▀ ▄ █ ▌ ▐ ░ ▒ ▬ ♦ ◊

PS:我也欢迎有关这些字符的一般信息,它们的名称和内容(ASCII,Unicode)?

4

6 回答 6

2
于 2012-04-26T01:09:47.847 回答
1

我以前见过这样做(星星),我认为这是一个很棒的主意!使用充满图标的字体(带有@font-face)也变得非常流行,例如:http: //fortawesome.github.com/Font-Awesome/

我看不出使用像“font awesome”这样的字体有任何缺点(只有你提到的优点,比如可伸缩性和使用 CSS 改变颜色的能力)。也许使用您提到的特殊字符有一个缺点,但我不知道。

于 2012-04-26T00:33:51.957 回答
1

使用这些字符的问题在于,并非所有字符都适用于所有用户使用的所有字体,这意味着您的应用程序可能看起来很奇怪,或者在最坏的情况下无法使用。也就是说,假设某些常见字体(Apple/Microsoft 的 Arial、Bitstream Vera)中可用的字符变得越来越普遍。您甚至不能假设您可以下载字体,因为某些用户可能会使用 Instapaper 或 Read It Later 等服务捕获内容以供离线阅读。

于 2012-04-26T00:38:07.950 回答
1

有很多问题:

可移植性:在代码中使用 7 位 ASCII 字符以外的任何字符都会降低您的代码的可移植性,因为接收者可能使用了错误的编码。您可以做很多事情来缓解这种情况(例如,使用 UTF16 或至少使用 UTF-8 编码的文件)。大多数语言允许您使用某种形式的转义符号(例如,C# 中的“\u1234”)在字符中指定字符串,这样可以避免该问题,但会失去一些优势。

字体依赖性:依赖于字体中可用特殊字符的用户界面元素可能更难国际化,因为这些字形可能不在您希望/需要用于特定受众的字体中。

没有颜色,艺术选择有限:虽然字体字形对程序员来说似乎很有用,但对于 UI 设计师来说,它们可能看起来很糟糕。

于 2012-04-26T00:39:24.683 回答
1

The question is very broad; it could be split to literally thousands of questions of the type “why shouldn’t I use character ... in HTML documents?” This seems to be what the question is about—not really about code. And it’s about characters, seen as “weird” or “uncommon” or “special” from some perspective, not about character encodings. (None of the characters mentioned are encoded in ASCII. Some are encoded in ISO-8895-1. All are encoded in Unicode.)

The characters are used in HTML documents. There is no general reason against not using them, but loads of specific reasons why some specific characters might not be the best approach in a specific situation.

For example, the “little dots” you mention in your example (probably not dots at all but circles or bullets), when used as control elements as you describe, would mean poor usability and poor accessibility. Making them significantly larger would improve the situation, but this more or less proves that such text characters are not suitable for controls.

Screen readers could make sense of special characters if they used a database of various properties of characters. Well, they don’t, and they often fail to read properly even the most common special characters. Just reading the Unicode name of a character can be cryptic or outright misleading. The proper reading would generally depend on meaning and context.

The main issue, however, is that people do not generally recognize characters in the meanings that you would assign to them. How many people know what the circled plus symbol “⊕” stands for? Maybe 1 out of 1,000, optimistically thinking. It might be all right to use in on a page about advanced mathematics or physics, especially if the notation is defined there. But used in general text, it would be just… a weird character, and people would read different meanings into it, or just get puzzled.

So using special characters just because they look cool isn’t a good idea. Even when there is time and place for a special character, there are technical issues with them. How many fonts do you expect to contain “⊕”? How many of those fonts do you expect Joe Q. Public to have in his computer? In this specific case, you would find the font coverage reasonably good, but you would still have to analyze it and write a longish list of font names in your CSS code to cover most platforms. In the pile of poo case (♨), it would be unrealistic to expect most people to see anything but a symbol for unrepresentable character. Regarding the methods of finding out such things, check out my Guide to using special characters in HTML.

于 2012-04-26T06:20:40.317 回答
0

I've run into problems using unusual characters: the tools editor, compiler, interpreter etc.) often complain and report errors. In the end, it wasn't worth the hassle. Darn western hegemony, or homogeneity, or, well, something!

于 2012-04-26T08:13:31.590 回答