472,354 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 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 1469
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.