home *** CD-ROM | disk | FTP | other *** search
-
- <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
-
- <!-- #include virtual="/quickstart/aspplus/include/header.inc" -->
-
- <h4>Setting Culture and Encoding</h4>
-
- <div class="indent" style="font-family:Verdana; font-size:8pt;">
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#encodings">Encodings</a><br>
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#cultureinfo">Using CultureInfo</a><br>
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#encoding">Using RegionInfo</a><br>
- </div>
-
- <p>
- <hr>
-
- <!--BEGIN SECTION-->
- <a name="encodings">
- <span class="subhead">Encodings</span>
-
- <p>
- Internally ASP+ handles all string data as Unicode. By using the <b>ResponseEncoding</b>
- attribute in the following sample , ASP+ is asked to send the page also with
- UTF-8 encoding. Note, that any arbritrary encoding could be chosen without
- affecting the .aspx file. ASP+ also sets the charset attribute on the
- Content-Type of the HTTP header according to the value of ResponseEncoding.
- This enables browsers to determine the encoding without the need to require a
- meta tag or to guess the right encoding from the content.
- <p>
-
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/i18n_encodings.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/i18n_encodings.src"
- Icon="/quickstart/aspplus/images/encoding1.gif"
- Caption="i18n_encodings.aspx"
- runat="server" />
-
- <p>
- <i>
- (Note, that if some characters show up
- as empty rectangles, you have to install the additional language
- support for Japanese and Hebrew: On Windows 2000 open the Regional Options on the
- Control Panel and add the required language support.)
- </i>
- <p>
-
- This sample demonstrates using different national character sets
- on the same page. The page contains English text (ASCII), German
- text (contains one umlaut character), Japanese text and Hebrew
- text (uses dir="rtl"). The source for the page itself is stored
- with codepage-neutral UTF-8 encoding, as specified in config.web:
-
- <div class="code"><xmp>
- <configuration>
- <globalization
- fileencoding="utf-8"
- ...
- />
- </configuration>
- </xmp></div>
- <p>
-
- On the page itself the ResponseEncoding is specified on the
- Page directive:
-
- <div class="code"><pre>
- <%@Page ... ResponseEncoding="utf-8"%>
- </pre></div>
- <p>
-
- Note, that the responseencoding in config.web is also specified as "utf-8",
- so that repeating it on the page is redundant. But if the .aspx file is
- moved to another server, which does not use utf-8, the file would still
- specify the right encoding.
-
-
- <!--BEGIN SECTION-->
- <br>
- <a name="cultureinfo">
- <br>
- <span class="subhead">Using CultureInfo</span>
- <p>
-
- Code on ASP+ pages can use the <b>CultureInfo</b> class to supply
- localized settings. In the following sample, the properties of
- a culture are displayed, initially the culture of the server:
-
- <div class="code"><xmp>
- culture = CultureInfo.CurrentCulture;
- </xmp></div>
-
- If the name of a new culture is submitted, it will be used
- instead:
- <div class="code"><xmp>
- culture = new CultureInfo(NewCulture.Value);
- </xmp></div>
-
- The submitted culture is set to be the new default value and
- some properties are displayed:
- <div class="code"><pre>
- <%
- Thread.CurrentThread.CurrentCulture = culture;
- %>
- ...
- Current Culture is <%= CultureInfo.CurrentCulture.Name %>
- (<%=Thread.CurrentThread.CurrentCulture.Name%>),
- <%= CultureInfo.CurrentCulture.EnglishName %>/<%=CultureInfo.CurrentCulture.NativeName%>,
- The localized date is: <%= DateTime.Now.Format("D", CultureInfo.CurrentCulture) %>
- </pre></div>
-
- <p>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/i18n_cultureinfo.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/i18n_cultureinfo.src"
- Icon="/quickstart/aspplus/images/encoding2.gif"
- Caption="i18n_cultureinfo.aspx"
- runat="server" />
-
-
-
- <!--BEGIN SECTION-->
- <br>
- <a name="region">
- <br>
- <span class="subhead">Using RegionInfo</span>
- <p>
-
- Code on ASP+ pages can use the <b>RegionInfo</b> class to also supply
- regional settings. In the following sample the properties of
- a region are displayed, initially the default region of the server:
-
- <div class="code"><pre>
- region = RegionInfo.CurrentRegion;
- ...
- Current region is <%= region.EnglishName %> (<%=region.NativeName%>),
- currency is <%= region.CurrencySymbol %>.
- </pre></div>
-
- On subsequent requests the entered region is displayed:
- <div class="code"><xmp>
- region = new RegionInfo(NewRegion.Value);
- </xmp></div>
-
-
-
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/i18n_regional.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/i18n_regional.src"
- Icon="/quickstart/aspplus/images/encoding3.gif"
- Caption="I18N_Regional.aspx"
- runat="server" />
-
-
-
-
- <h4>Section Summary</h4>
- <ol>
- <li>ASP+ can use pages, which are stored with utf-8 encoding, to support different national characters.
- <li>The CultureInfo class can be set and used programmatically to localize pages.
- <li>The RegionInfo class can be used to provide regional settings on ASP+ pages.
- </ol>
-
- <!-- #include virtual="/quickstart/aspplus/include/footer.inc" -->
-
-
-
-
-
-
-
-
-
-