Thursday, March 22, 2007

Using Server.HTMLEncode on Classic ASP

If you have an ASP pages that display strings stored in the database fields, you should always process the strings with the Server.HTMLEncode method, otherwise the string won't be displayed correctly in the user's browser if it contains characters that have a special meaning to HTML, such as the quote ("), the less-than (<) and greater-than (>) symbols, the ampersand symbol (&), and any character whose ANSI code is larger than 127.

It is easy to hardcode these things into our ASP script, but if these characters exist in your database, you need to dynamically encode them. To do so, apply the HTMLEncode method to your recordset data before it is sent to the response object:

Response.Write Server.HTMLEncode(rs.Fields("my_field"))

Other examples is:

<%
Dim sLink

sLink = "<a href="'http://www.printerspost.com.au'">Printers Post Australia</a>"

Response.Write "Not HTMLEncoded string: " & sLink & "<br/><br/>"
Response.Write "HTMLEncoded string:" & Server.HTMLEncode(sLink)

%>

Monday, March 19, 2007

DKU-5 vs CA-42 Data Cable

Hello all, now i want to explain the differences between Nokia DKU-5 and CA-42 data cable. Sometime we are confusing to choose a data cable for our Nokia Phone. There are DKU-5 and CA-42 data cable. I hope this article helping you who are decided to buy a Nokia data cable.

DKU-5

DKU-5 has a chip in it to emulate a serial port through the USB connector. This is for phones without native USB connectivity. DKU-5 is used for models without external memory (6100, 3100, 3120, 3200, 3220, 6610, 7210, 7250, 68xx, 6200, 6220).

CA-42

CA-42 is a replacement cable for DKU-5 cable. Some phones are compatible with both of them, some with just CA-42.

The main differences are three :
  1. The CA-42 cable consumes less power than the DKU-5 when it is idle.
  2. The CA-42 cable is not detected by the PC unless the phone is connected to the other end.
  3. The CA-42 cable can be also used in Operating Systems other than Windows 98/2K/XP, such as Windows CE, Linux and Mac.

Thursday, March 15, 2007

Session.LCID (LOCALE ID)

When we are developing a website using ASP script, sometime we had to format dates, numbers, currency, etc. by ourself. And relying on the version of Windows that was installed on the server, it is not good idea in case you moved sites from say The United States to a United Kingdom provider. With IIS4 and IIS5 (Windows NT4 and Windows 2000 respectively) you only need to set the LOCALE ID (Session.LCID) and everything is done for you. The Session.LCID is a read/write property, meaning you can assign a value to it as well as read its current value.

Session.LCID has session scope, which means you can just add one line of code to your global.asa file and ASP does the rest for you. Just remember that if you assign a new value to the Session.LCID it will override global.asa and will remain until a new value is set or the session is ended.

Below you can see locale id's for the US and the UK as well as how dates are formatted using these locales.

Session.LCID = 1033 'This is the English(United States) format.

Short Date : 3/15/2007
Long Date : Thursday, March 15, 2007
Time : 12:11:02 AM
Currency : $9.95

Session.LCID = 2057 'This is the English(British) format

Short Date : 15/03/2007
Long Date : 15 March 2007
Time : 00:11:02
Currency : Ј10.00

When working with databases, you will want to also set the format of the date field to correspond with the LCID that is being used in the script. You can do this by going into the design view and setting the format to dd/mm/yyyy or the format you are using.

Below is a table of the LCIDs, and the corresponding language that you have available:

LOCALE ID :

LCID____Language
-----------------------------
1078____Afrikaans
1052____Albanian
5121____Arabic(Algeria)
15361___Arabic(Bahrain)
3073____Arabic(Egypt)
2049____Arabic(Iraq)
11265___Arabic(Jordan)
13313___Arabic(Kuwait)
12289___Arabic(Lebanon)
4097____Arabic(Libya)
6145____Arabic(Morocco)
8193____Arabic(Oman)
16385___Arabic(Qatar)
1025____Arabic(Saudi Arabia)
10241___Arabic(Syria)
7169____Arabic(Tunisia)
14337___Arabic(U.A.E.)
9217____Arabic(Yemen)
1069____Basque
1059____Belarusian
1026____Bulgarian
1027____Catalan
3076____Chinese(Hong Kong)
2052____Chinese(PRC)
4100____Chinese(Singapore)
1028____Chinese(Taiwan)
1050____Croatian
1029____Czech
1030____Danish
2067____Dutch(Belgian)
1043____Dutch(Standard)
9_______English
3081____English(Australian)
10249___English(Belize)
2057____English(British)
4105____English(Canadian)
9225____English(Caribbean)
6153____English(Ireland)
8201____English(Jamaica)
5129____English(New Zealand)
7177____English(South Africa)
11273___English(Trinidad)
1033____English(United States)
1061____Estonian
1080____Faeroese
1065____Farsi
1035____Finnish
2060____French(Belgian)
3084____French(Canadian)
5132____French(Luxembourg)
1036____French(Standard)
4108____French(Swiss)
2108____Gaelic(Irish)
1084____Gaelic(Scots)
3079____German(Austrian)
5127____German(Liechtenstein)
4103____German(Luxembourg)
1031____German(Standard)
2055____German(Swiss)
1032____Greek
1037____Hebrew
1081____Hindi
1038____Hungarian
1039____Icelandic
1057____Indonesian
1040____Italian(Standard)
2064____Italian(Swiss)
1041____Japanese
1042____Korean
2066____Korean(Johab)
1062____Latvian
1063____Lithuanian
1071____Macedonian
1086____Malaysian
1082____Maltese
1044____Norwegian(Bokmal)
2068____Norwegian(Nynorsk)
1045____Polish
1046____Portuguese(Brazilian)
2070____Portuguese(Standard)
1047____Rhaeto-Romanic
1048____Romanian
2072____Romanian(Moldavia)
1049____Russian
2073____Russian(Moldavia)
1083____Sami(Lappish)
3098____Serbian(Cyrillic)
2074____Serbian(Latin)
1051____Slovak
1060____Slovenian
1070____Sorbian
11274___Spanish(Argentina)
16394___Spanish(Bolivia)
13322___Spanish(Chile)
9226____Spanish(Colombia)
5130____Spanish(Costa Rica)
7178____Spanish(Dominican Republic)
12298___Spanish(Ecuador)
17418___Spanish(El Salvador)
4106____Spanish(Guatemala)
18442___Spanish(Honduras)
2058____Spanish(Mexican)
19466___Spanish(Nicaragua)
6154____Spanish(Panama)
15370___Spanish(Paraguay)
10250___Spanish(Peru)
20490___Spanish(Puerto Rico)
3082____Spanish,Spain-Modern Sort
1034____Spanish(Spain - Traditional Sort)
14346___Spanish(Uruguay)
8202____Spanish(Venezuela)
1072____Sutu
1053____Swedish
2077____Swedish(Finland)
1054____Thai
1073____Tsonga
1074____Tswana
1055____Turkish
1058____Ukrainian
1056____Urdu
1075____Venda
1066____Vietnamese
1076____Xhosa
1085____Yiddish
1077____Zulu
2048____default