Welcome Guest! You need to login or register to make posts.



Go to last post Go to first unread
#1 Posted : Sunday, May 25, 2003 9:19:00 PM(UTC)

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,659

Thanks: 5 times
Was thanked: 76 time(s) in 74 post(s)

Variety of languages sometimes causes problems when we deal with text drawing. Everything may work ok, until you try to draw a string which contains non-english symbols, especially such complex characters as Japanise, Arabic, Chinese and so on. For example you write an application in ASP and try to draw such characters you can receive the following:


instead of:



ASP file has incorrect encoding. That's why wrong symbols are passed to the Graphics Processor and it cannot draw it correctly.


To make Graphics Processor draw such symbols correctly, you should set right encoding to the file which contains the script.

Let's assume that we have draw text via the following code:

Option Explicit
' Create RasterObject
Dim objRaster
Set objRaster = Server.CreateObject("GraphicsProcessor2002.RasterObject")
objRaster.EmptyImage 200, 50
' Create DrawingTool
Dim objDT
Set objDT = Server.CreateObject("GraphicsProcessor2002.DrawingTool")
objDT.AntialiasingOn = True
' Adjust font settings
objDT.DefaultTextInfo.FontSize = 18
objDT.DefaultTextInfo.IsBold = False
objDT.DefaultTextInfo.IsItalic = True
Dim strText, dblTextWidth, dblTextHeight
strText = "Text..."
' Draw it on the RasterObject
objDT.RasterObject = objRaster
objDT.SetText strText,0,0
' Save it to browser
objRaster.EncoderOptions("OutputFileType") = "GIF"
objRaster.SaveStream Response
objRaster.SaveFile Server.MapPath("measure.gif")
Set objRaster = Nothing

Replace strText variable value into some text on necessary language, something like this:


As the file contains non-English characters, we should specify the text encoding in order it could be read correctly. For example we could use UTF-8 (UTF-16 is not supported in ASP). To use UTF-8 you should do two things:

1. Specify in the beginning of ASP page that you are going to use this encoding. To do it, just insert the following string in the beginning of the ASP page:

<% CodePage=65001 %>

2. Save ASP file using UTF-8 encoding. Note, you should select UTF-8 encoding with signature. If you work in Visual Studio .NET you can specify the encoding in the following way:


and then


After that you can save file as usual, it will be saved using right encoding.

You can also open encoding options dialog directly from Save dialog:


If you edit the file in Notepad, you can just select UTF-8 encoding in Save dialog:


Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.