diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
| commit | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch) | |
| tree | d4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/de/web/javascript/reference/global_objects/encodeuri | |
| parent | 33058f2b292b3a581333bdfb21b8f671898c5060 (diff) | |
| download | translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2 translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip | |
initial commit
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/encodeuri')
| -rw-r--r-- | files/de/web/javascript/reference/global_objects/encodeuri/index.html | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/encodeuri/index.html b/files/de/web/javascript/reference/global_objects/encodeuri/index.html new file mode 100644 index 0000000000..2b8521f9e7 --- /dev/null +++ b/files/de/web/javascript/reference/global_objects/encodeuri/index.html @@ -0,0 +1,163 @@ +--- +title: encodeURI() +slug: Web/JavaScript/Reference/Global_Objects/encodeURI +translation_of: Web/JavaScript/Reference/Global_Objects/encodeURI +--- +<div>{{jsSidebar("Objects")}}</div> + +<p>Die <code><strong>encodeURI()</strong></code> Funktion kodiert ein Uniform Resource Identifier (Abk. URI, englisch für einheitlicher Bezeichner für Ressurcen), indem sie jedes Vorkommen von speziellen Zeichen durch die jeweilige UTF-8 Zeichenkette ersetzt, die das Zeichen repräsentiert.</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox"><code>encodeURI(<em>URI</em>)</code></pre> + +<h3 id="Parameter">Parameter</h3> + +<dl> + <dt><code>URI</code></dt> + <dd>Ein vollständiger Uniform Resource Identifier.</dd> +</dl> + +<h3 id="Return_value">Return value</h3> + +<p>Ein neuer String, kodiert als Uniform Resource Identifier (URI).</p> + +<h2 id="Beschreibung">Beschreibung</h2> + +<p>Die Funktion geht davon aus, dass die URI eine richtige URI ist, sodass sie keine Zeichen kodiert die spezielle Bedeutungen haben.</p> + +<p><code>encodeURI</code> ersetzt alle Zeichen <strong>außer </strong>die folgenden<strong> </strong>mit ihrer zugehörigen UTF-8 Escape-Sequenz:</p> + +<table class="standard-table"> + <tbody> + <tr> + <td class="header">Typ</td> + <td class="header">Beinhaltet</td> + </tr> + <tr> + <td>Zurückgehaltene Zeichen</td> + <td><code>;</code> <code>,</code> <code>/</code> <code>?</code> <code>:</code> <code>@</code> <code>&</code> <code>=</code> <code>+</code> <code>$</code></td> + </tr> + <tr> + <td>Unescapte </td> + <td>alphanumerische Zeichen, <code>-</code> <code>_</code> <code>.</code> <code>!</code> <code>~</code> <code>*</code> <code>'</code> <code>(</code> <code>)</code></td> + </tr> + <tr> + <td>Zeichen für Nummern</td> + <td><code>#</code></td> + </tr> + </tbody> +</table> + +<p>Beachten Sie, dass die <code>encodeURI</code> Funktion keine richtigen HTTP GET und POST Requests erzeugen kann, wie für XMLHTTPRequests benötigt, da "&", "+", und "=" nicht kodiert werden. Diese werden in GET und POST als spezielle Zeichen behandelt. Für solche Verwendungen steht die {{jsxref("encodeURIComponent")}} Funktion zur Verfügung.</p> + +<p>Beachten Sie auch, dass ein {{jsxref("URIError")}} erzeugt wird, sobald versucht wird, ein <a href="https://de.wikipedia.org/wiki/UTF-16#Kodierung">surrogate</a>, welches nicht zu einem high-low Paar gehört, zu kodieren.</p> + +<pre class="brush: js">// high-low paar ok +console.log(encodeURI('\uD800\uDFFF')); + +// einzelnes high surrogate erzeugt ein "URIError: malformed URI sequence" +console.log(encodeURI('\uD800')); + +// einzelnes low surrogate erzeugt ein "URIError: malformed URI sequence" +console.log(encodeURI('\uDFFF')); </pre> + +<p>Wenn Sie den neueren <a href="http://tools.ietf.org/html/rfc3986">RFC3986</a> Standart für URLs benutzen möchten, der eckige Klammern beachtet (für IPv6) und Teile die zur URL gehören könnten (wie der Host) nicht kodiert, könnte der kleine Code-Auszug helfen:</p> + +<pre class="brush: js">function fixedEncodeURI(str) { + return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']'); +}</pre> + +<h2 id="Spezifikationen">Spezifikationen</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Spezifikation</th> + <th scope="col">Status</th> + <th scope="col">Kommentar</th> + </tr> + <tr> + <td>{{SpecName('ES3')}}</td> + <td>{{Spec2('ES3')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.1.3.3', 'encodeURI')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-encodeuri-uri', 'encodeURI')}}</td> + <td>{{Spec2('ES6')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-encodeuri-uri', 'encodeURI')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_kompatibilität">Browser kompatibilität</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Normale Unterstützung</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td> + <p>Normale Unterstützung</p> + </td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li>{{jsxref("decodeURI")}}</li> + <li>{{jsxref("encodeURIComponent")}}</li> + <li>{{jsxref("decodeURIComponent")}}</li> +</ul> |
