1

I am implementing uploading image feature and struggling when deciding whether to strip off non-english chars and spaces.

In my language, we have alphabetical characters just like in English except for a few: â, ơ, ù, ...

For example:

  1. An original file name would be: 145_Quản trị năng lượng cấp cao_ori

  2. If I strip off non-english chars: 145_Quan tri nang luong cap cao_ori

  3. If I take a step further replacing spaces: 145_Quan-tri-nang-luong cap-cao_ori

  4. I may as well replacing spaces only: 145_Quản-trị-năng-lượng-cấp-cao_ori

I'm concerned about SEO ability of the image and browsers' support for loading images like these.

Which one of the above approaches would be the best?

4

1 回答 1

0

嗯,你有两个问题——最好把它们分开,清楚地理解它们。

  1. 哪些字符对磁盘上的文件名有效?这些决定了您应该上传和存储的文件名。这取决于操作系统和文件系统。为了便于携带,您可以选择存储重音字符。

  2. 哪些字符对标题和 URL 有效?这些决定了您将在其下存储和呈现这些的 TITLE 或 URL,并且对 SEO 可见。如果可能的话,我认为你绝对应该在这里使用越南语——因为人们会寻找它!

根据现代 URL 标准,您可以在 URL 中使用 UTF-8 编码后跟 % 字节编码来编码所有 Unicode 字符。

长话短说,我会在数据库中使用两列,保持文件名简单且可移植,但将完整的 UTF-8 公开为 URL 中的标题和。

看:

于 2013-11-05T03:45:16.937 回答