473,418 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Unicode question

Hi Team,

I'm not an expert in ASP but can manage. I am writing a script to randomly select text from the database. (Microsoft Access). The database has (Sankrit font) Proverbs that I am displaying randomly on the home page. The script that I have written does the job but when displaying the text I get (????????????????????/???) I'm sure it is problem with text that needs to be displayed. here is an ex: of what is stored in the databse.

नेहाभिक्रमनाशोस्ति प्रत्यवायो न विद्यते ।
स्वल्पमप्यस्य धर्मस्य त्रायते महतो भयात् ॥२-४०॥

When I run the script for showing all the records in the table the proverb is shown perfectly but it is not the same on when showing randomly. I'm not sure why?

Below is the script that I have used for random.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     Option Explicit
  3.     Response.Buffer = True
  4. %>
  5. <html>
  6. <head>
  7.     <style>
  8.     p { font-family:verdana; font-size:11px; }
  9.     </style>
  10. </head>
  11. <body>
  12. <br><p align="center">
  13. <%
  14.     ' ADO Constant. Dont change this
  15.     Const adCmdText = &H0001
  16.  
  17.         ' Connection string and SQL statement
  18.     Dim query, connStr
  19.         query = "select sloka from Slokas"
  20.         connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
  21.                 Server.MapPath("slokas.mdb")
  22.  
  23.         ' Opening database
  24.     Dim rs
  25.         Set rs = Server.CreateObject("ADODB.Recordset")
  26.         rs.Open query, connStr, 3, , adCmdText
  27.  
  28.         ' Generating random number from total number of records
  29.     Dim intRnd
  30.         Randomize Timer
  31.         intRnd = (Int(RND * rs.RecordCount))
  32.  
  33.         ' Now moving the cursor to random record number
  34.         rs.Move intRnd
  35.  
  36.         ' Showing the random statement
  37.         Response.Write "<b>" & rs("Sloka") & "</b>"
  38.  
  39.         ' Closing the database
  40.         rs.Close
  41.         Set rs = Nothing
  42. %>
  43. </p>
  44. </body>
  45. </html>
Can you please let me know where I have gone wrong?

Thanks,
Raam
Sep 5 '07 #1
5 1523
jhardman
3,406 Expert 2GB
Raam,

This is an HTML issue, as far as I know. Are you stating a text encoding in the HTML?

Jared
Sep 5 '07 #2
markrawlingson
346 Expert 100+
I would take a look at your randomizer function first.

If there is only 1 record in your database it will always return as 0.

RND generates a random number between 0 and 1 (eg: 0.23421)
INT, simply drops any numbers after the decimal place. So say RND generates even the maximum number it can...

0.999 * 1 = 0.999

With INT wrapped around that it will drop anything after the decimal place and return 0. It does not round up like a lot of people think it does.

Also, even if the database always has more than 1 record - that randomizer function can return 0 still.

Say the db has 5 records and RND returns 0.020

0.020 * 5 = 0.100

With INT wrapped around it 0.100 = 0

In addition - Because of that, the last record in the database will never get displayed. If the recordCount is 10 - the maximum number that will be returned is 9, if the recordcount is 20 - the maximum number that will be returned is 19 - etc etc.

Fairly certain that's not what's causing the ????? to be displayed but it's still important and I just though i'd mention that... cause you can't move to record 0...

But it's an easy fix.

Expand|Select|Wrap|Line Numbers
  1. Int(RND * rs.RecordCount + 1)
  2.  
Sep 6 '07 #3
Raam,

This is an HTML issue, as far as I know. Are you stating a text encoding in the HTML?

Jared
Nope I am not.. actually i'm just printing what ever is there in the datbase...!! So it should actually print what ever is there... just confused with it?
Sep 8 '07 #4
I would take a look at your randomizer function first.

If there is only 1 record in your database it will always return as 0.

RND generates a random number between 0 and 1 (eg: 0.23421)
INT, simply drops any numbers after the decimal place. So say RND generates even the maximum number it can...

0.999 * 1 = 0.999

With INT wrapped around that it will drop anything after the decimal place and return 0. It does not round up like a lot of people think it does.

Also, even if the database always has more than 1 record - that randomizer function can return 0 still.

Say the db has 5 records and RND returns 0.020

0.020 * 5 = 0.100

With INT wrapped around it 0.100 = 0

In addition - Because of that, the last record in the database will never get displayed. If the recordCount is 10 - the maximum number that will be returned is 9, if the recordcount is 20 - the maximum number that will be returned is 19 - etc etc.

Fairly certain that's not what's causing the ????? to be displayed but it's still important and I just though i'd mention that... cause you can't move to record 0...

But it's an easy fix.

Expand|Select|Wrap|Line Numbers
  1. Int(RND * rs.RecordCount + 1)
  2.  
As of now I have 5 records in the database and it is randomizing perfectly. I tested it with one record as "Test Record number 5" as the text I get this text perfectly other text are randomized with showing "???????????"
Sep 8 '07 #5
jhardman
3,406 Expert 2GB
Nope I am not.. actually i'm just printing what ever is there in the datbase...!! So it should actually print what ever is there... just confused with it?
This is the problem then (as far as I can tell). Browsers are set up to display english characters by default. To let them know there are other characters you need to include a note saying which set of character codes you are going to use. Here is Wikipedia's explanation, which shows how to set the encoding tag. Here is an old site I found which explains how to display sanskrit characters. I hope this helps. I wouldn't be able to test this for you since I do not have those fonts installed on my computer.

Jared
Sep 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: sebastien.hugues | last post by:
Hi I would like to retrieve the application data directory path of the logged user on windows XP. To achieve this goal i use the environment variable APPDATA. The logged user has this name:...
9
by: François Pinard | last post by:
Hi, people. I hope someone would like to enlighten me. For any application handling Unicode internally, I'm usually careful at properly converting those Unicode strings into 8-bit strings before...
27
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
3
by: Supratim | last post by:
Hi, For past few weeks I am working on a function that would take encoded Unicode characters from query string of http requests and then decode them back to Unicode numbers. I have full success...
3
by: dalei | last post by:
My question is presented more clearly in following web page: http://www.pinyinology.com/signs2.html <html> HTML entities display outside script tags: a&sup1;, a&sup2;, a&sup3;, a⁴ But...
12
by: damjan | last post by:
This may look like a silly question to someone, but the more I try to understand Unicode the more lost I feel. To say that I am not a beginner C++ programmer, only had no need to delve into...
14
by: abhi147 | last post by:
Hi , I want to convert an array of bytes like : {79,104,-37,-66,24,123,30,-26,-99,-8,80,-38,19,14,-127,-3} into Unicode character with ISO-8859-1 standard. Can anyone help me .. how should...
2
by: willie | last post by:
Martin v. Löwis: Thanks for the thorough explanation. One last question about terminology then I'll go away :) What is the proper way to describe "ustr" below? <type 'unicode'>
5
by: =?Utf-8?B?S2V2aW4gVGFuZw==?= | last post by:
In MFC, CRichEditCtrl contrl, I want to set the codepage for the control to Unicode. I used the following method to set codepage for it (only for ANSI or BIG5, etc, not unicode). How should I...
0
by: deloford | last post by:
Hi This is going to be a question for anyone who is an expert in C# Text Encoding. My situation is this: I have a Sybase database which is firing back ISO-8559 encoded strings. I am unable to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.