Show code in...     

  

 

Object Model ExcelApplication Worksheets Worksheet Cells Cell Range
Charts Chart SeriesCollection Series 3DProperties Axis ChartFrame Line Area
PivotField PivotFields PivotTable PivotTables
Style Characters Font Pictures Picture DocumentProperties PageSetup


ExcelApplication Object Reference

UnicodeToAnsi Method


Syntax:
[VBScript]
Function UnicodeToAnsi(inUnicode As String, CodePage As Long) As String
Description:

To get a non-Latin alphabet string from a spreadsheet, and display the string correctly in the browser, from a server running a language different from the language of the client's HTML page, you must:

  1. Set the ExcelWriter script's charset property to the string language's charset.
  2. Use the UnicodeToAnsi method to convert the string to an Ansi encoded string that can be displayed correctly to the user.

UnicodeToAnsi takes a Unicode string and the string language's code page and returns an Ansi string.

For a complete list of charset and code page values see, Character Set Recognition.

Example:

Cell E7 contains a Hebrew string represented in Unicode. The following lines convert the string from Unicode to Ansi, and display the converted string in the browser. The Hebrew characters will be displayed correctly. The example uses a specific language code page and charset; to correctly display strings in any language, use code page 65001 and charset UTF-8.

[VBScript]
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=windows-1255">
<% 
Set xlw = Server.CreateObject("Softartisans.ExcelWriter")
...
response.write xlw.unicodetoansi(order.cells("E7").value, 1255)
...
%>

Top


Copyright © 2005, SoftArtisans, Inc.