Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat encoding scheme should be used in a web project?
    primarykey
    data
    text
    <p>We are building a (Java) web project with Eclipse. By default Eclipse uses <code>Cp1252</code> encoding on Windows machines (which we use).</p> <p>As we also have developers in China (in addition to Europe), I started to wonder if that is really the encoding to use.</p> <p>My initial thought was to convert to <code>UTF-8</code>, because <em>"it supports all the character sets"</em>. However, is this really wise? Should we pick some other encoding instead? I see couple of issues:</p> <p>1) How do web browser interpret the files by default? Does it depend on what language version one is using? What I am after here is that should we verbosely declare the encoding schemes used:</p> <ul> <li>XHTML files can set the encoding verbosely using <code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;</code> declarations.</li> <li>CSS files can set this by <code>@CHARSET "UTF-8";</code>.</li> <li>JavaScript files do not have in-file declarations, but one can globally define <code>&lt;meta http-equiv="Content-Script-Type" content="text/javascript; charset=utf-8"&gt;</code> or <code>&lt;script type="text/javascript" charset="utf-8"&gt;</code> for specific scripts.</li> </ul> <p>What if we leave CSS file without <code>@CHARSET "UTF-8";</code> declaration? How does the browser decide how it is encoded?</p> <p>2) Is it wise to use UTF-8, because it <em>is</em> so flexible. By locking our code into <code>Cp1252</code> (or maybe <code>ISO-8859-1</code>) I can ensure that foreign developers don't introduce special characters into files. This effectively prevents them from inserting Chinese comments, for example (we should use 100% english). Also, allowing UTF-8 can sometimes allow developers accidentally introduce some strange characters, that are difficult/impossible to perceive with human eye. This occurs when people, for example, copy-paste text or happen to press some weird keyboard combination accidentally.</p> <p>It would seem that allowing UTF-8 in the project just brings problems...</p> <p>3) For internatioanlization, I initially considered UTF-8 a good thing ("how can you add translations if the file encoding doesn't support the characters one needs?"). However, as it turned out, Java Resource Bundles (.properties files) <em>must</em> be encoded with ISO-8859-1, because otherwise they might break. Instead, the international characters are converted into <code>\uXXXX</code> notation, for example <code>\u0009</code> and the files are encoded with <code>ISO-8859-1</code>. So... we are not even able to use UTF-8 for this.</p> <p>For binary files... well, the encoding scheme doesn't really matter (I suppose one can say it doesn't even exist).</p> <p>How should we approach these issues?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload