home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / aspplus / doc / internationalization.aspx < prev    next >
Encoding:
Text File  |  2000-06-08  |  5.4 KB  |  152 lines

  1. <%@Page Language="C#" ResponseEncoding="utf-8" %>
  2. <%@Import Namespace="System.Globalization"%>
  3. <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
  4.  
  5. <!-- #include virtual="/quickstart/aspplus/include/header.inc" -->
  6.  
  7. <h4>Internationalization Overview</h4>
  8.  
  9.  
  10. <div class="indent" style="font-family:Verdana; font-size:8pt;">
  11.     <b> <img align="middle" src="/quickstart/images/bullet.gif">  </b>
  12.     <a class="toc2" target="content" href="#encoding">Encoding Support</a><br>
  13.     <b> <img align="middle" src="/quickstart/images/bullet.gif">  </b>
  14.     <a class="toc2" target="content" href="#localization">Localization Support</a><br>
  15.     <b> <img align="middle" src="/quickstart/images/bullet.gif">  </b>
  16.     <a class="toc2" target="content" href="#config">Configuration Settings</a><br>
  17. </div>
  18.  
  19. <p>
  20. <hr>
  21.  
  22. <!--BEGIN SECTION-->
  23. <a name="encoding">
  24. <span class="subhead">Encoding Support</span>
  25. <p>
  26.  
  27. ASP+ internally uses Unicode. In addition, ASP+ utilizes the String class of the 
  28. NGWS Base Class Library and the related utility functions, which are also 
  29. internally UNICODE. When interfacing with the outside world, ASP+ can
  30. be configured in several ways to use a defined encoding. This covers the encoding 
  31. of .aspx files, of request data and response data. It is, for example, possible to
  32. store .aspx files with Unicode encoding and convert the HTML output of a page to an
  33. ANSI codepage like <nobr>iso-8859-1</nobr>.
  34.  
  35. <!--BEGIN SECTION-->
  36. <br>
  37. <a name="localization">
  38. <br>
  39. <span class="subhead">Localization Support</span>
  40. <p>
  41.  
  42. Properties of a locale are accessible through the <b>CultureInfo</b> class.
  43. Additionally ASP+ tracks two values of a default culture per thread and request:
  44. <b>CurrentCulture</b> for the default of locale dependent functions
  45. and <b>CurrentUICulture</b> for locale-specific lookup of resource data.
  46. <p>
  47.  
  48. The following code snippet can be used to display the culture values on the web server
  49. (note, that the CultureInfo class is fully qualified):
  50. <div class="code"><pre>
  51. <%@Import Namespace="System.Globalization"%>
  52. ...
  53. <%=CultureInfo.CurrentCulture.NativeName%>
  54. <%=CultureInfo.CurrentUICulture.NativeName%>
  55. </pre></div>
  56.  
  57. <p>
  58. The result is...
  59. <p>
  60.  
  61. <div class="code">
  62. <%=System.Globalization.CultureInfo.CurrentCulture.NativeName%> <br>
  63. <%=System.Globalization.CultureInfo.CurrentUICulture.NativeName%>
  64. </div>
  65. <p>
  66.  
  67. For locale dependent data like date/time formats or currency ASP+ leverages
  68. the support of the Base Class Library in the NGWS runtime. Code on ASP+ pages can
  69. use locale-dependent formatting routines like <b>DateTime.Format</b>. The following
  70. code for example will display the current date in a long format, the first 
  71. line according to the system locale, the second one according to the
  72. German ("de") locale: 
  73.  
  74. <div class="code"><pre>
  75. <%=DateTime.Now.Format("f", null)%>
  76. <%=DateTime.Now.Format("f", new System.Globalization.CultureInfo("de"))%>
  77. </pre></div>
  78.  
  79. <p>
  80. The result is...
  81. <p>
  82.  
  83. <div class="code">
  84. <%=DateTime.Now.Format("f", null)%><br>
  85. <%=DateTime.Now.Format("f", new System.Globalization.CultureInfo("de"))%>
  86. </div>
  87.  
  88.  
  89. <!--BEGIN SECTION-->
  90.  
  91. <a name="config">
  92. <br>
  93. <span class="subhead">Configuration Settings</span>
  94. <p>
  95.  
  96. While creating ASP+ pages or code-behind modules, developers can use the 
  97. base class libraries to provide features necessary for a globalized environment 
  98. or to localize the application.
  99. Additionally ASP+ provides configuration settings to ease development and 
  100. administration of ASP+ applications.
  101. <p>
  102.  
  103. ASP+ utilizes configuration files to provide settings for a directory, which are
  104. usually also inherited by sub-directories. Each file can contain a 
  105. <globalization> section, where default encodings and cultures can be
  106. specified. Values are valid, if they are accepted by the related classes
  107. Encoding and CultureInfo.
  108.  
  109. <div class="code"><xmp>
  110. <configuration>
  111.  
  112. <globalization 
  113.    fileencoding="utf-8"
  114.    requestencoding="utf-8"
  115.    responseencoding="utf-8" 
  116.    culture="en-us"
  117.    uiculture="de"
  118. />
  119.     
  120. </configuration>
  121. </xmp></div>
  122.  
  123. The value of fileencoding determines the encoding ASP+ applies to .aspx files,
  124. requestencoding and responseencoding apply to request data and content sent
  125. as a response respectively.
  126. <p>
  127.  
  128. The attributes of the globalization section in config.web can also be specified on 
  129. the <%@Page ...%> directive (with the exception of fileencoding, as it applies
  130. to the file itself). These settings are only valid for the specific page and override
  131. the settings of the config file. The following sample directive defines, that the 
  132. page uses French culture settings and uses UTF-8 encoding for the response:
  133.  
  134. <div class="code"><pre>
  135. <%@Page Culture="fr" UICulture="fr" ResponseEncoding="utf-8"%>
  136. </pre></div>
  137. <p>
  138.  
  139. Note that within a page the culture values can be changed programmatically by setting
  140. <b>Thread.CurrentCulture</b> and <b>Thread.UICulture</b>.
  141. <p>
  142.  
  143. <h4>Section Summary</h4>
  144. <ol>
  145. <li>ASP+ offers support a wide range of encodings for .aspx files, request and response data.
  146. <li>Support for locale dependent data is given through the CultureInfo class, for which the two 
  147. values CurrentCulture and CurrentUICulture are tracked.
  148. <li>Internationalization settings can be configured per machine, per directory and per page.
  149. </ol>
  150.  
  151.  
  152. <!-- #include virtual="/quickstart/aspplus/include/footer.inc" -->