-5

I have a string "यदि आपको SALARY की EXPECTATION ज्यादा है तो आप WORK भी ज्यादा कीजिये !". This string contains Hindi and English words.

What I want is to display the very same string to my users. I tried putting same string in Text-box but it didn't work for me.

To make own Richtext Box may be an option for this, but I want Hindi fonts to be displayed in different Font say "Arial Black" and English should be displayed in different say "Arial Narrow". Also I have my own font that needs to be in Richtext Box to display Hindi words. And for English words I decided to show them in "Arial" with Bold fonts.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    If you want to display them in different fonts, you'll need to wrap a span around each part, so that you can set fonts separately in CSS. – halfer Jun 19 '13 at 08:55

2 Answers2

4

You need to set charset to utf-8 in the <head> section of the page

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

You need to put <span> tags around English and Hindi words so that you can set different font for them as suggested by @halfer

<span style="font-family:Arial Black;">यदि आपको</span>
<span style="font-family:Arial;">EXPECTATION </span>
Khawer Zeshan
  • 9,470
  • 6
  • 40
  • 63
  • 1
    Note these shouldn't be inline styles, but rather CSS classes.. – John Dvorak Jun 19 '13 at 09:03
  • @JanDvorak yes i agree. But i just wanted to give him an example how he can achieve this – Khawer Zeshan Jun 19 '13 at 09:05
  • Hello Zeshan and Jan, thanks for your responses. I tried this before also, but it didn't work for me. Let me tell you more on what I am looking for. I have a textbox wherein I want to write this Hindi-English string. I also have Font= "Priyanka" in which each Hindi or English words should be displayed. This Font is similar to "Arial". I'd like to know that how can I use this Font (Priyanka) in my textbox. For now I used/implemented this Font (Priyanka) in my textbox, but it changes my whole string in Priyank Font and then I can't see Hindi/English words. ` – still alone Jun 19 '13 at 09:12
  • 1
    @stillalone show us your attempt – John Dvorak Jun 19 '13 at 09:15
  • The reason I can't put every time is my client has MS Word file, wherein he has written such sort of strings (English-Hindi). I gave him a textbox. What all he does is he copies his string from Word file and pastes those strings in textbox. Then My code fetches that string from texbox (database) and displays it on user panel. I have no control on that string that is in textbox, so I can't put in the string. Please suggest me how can I get this done in easy steps. Thanks..!! – still alone Jun 19 '13 at 10:10
  • @stillalone: "Let me tell you more on what I am looking for". In future, if you can make updates to your question, rather than adding them piecemeal in various comments on the page, you'll find this will save time for new readers wanting to understand the whole problem. Great questions are entirely (or at least mostly) self-contained. – halfer Jun 19 '13 at 11:41
0

In your HTML page add in head section:

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Also you can do:

Changing the server encoding PHP header() function The simplest way to handle this problem is to send the encoding yourself, via your programming language. Since you're using HTML Purifier, I'll assume PHP, although it's not too difficult to do similar things in other languages. The appropriate code is:

header('Content-Type:text/html; charset=UTF-8');

...replacing UTF-8 with whatever your embedded encoding is. This code must come before any output, so be careful about stray whitespace in your application (i.e., any whitespace before output excluding whitespace within tags). PHP ini directive PHP also has a neat little ini directive that can save you a header call: default_charset. Using this code:

ini_set('default_charset', 'UTF-8');

...will also do the trick. If PHP is running as an Apache module (and not as FastCGI, consult phpinfo() for details), you can even use htaccess to apply this property across many PHP files:

php_value default_charset "UTF-8"

As with all INI directives, this can also go in your php.ini file. Some hosting providers allow you to customize your own php.ini file, ask your support for details. Use:

default_charset = "utf-8"
halfer
  • 19,824
  • 17
  • 99
  • 186
Goutam Pal
  • 1,763
  • 1
  • 10
  • 14
  • Thanks for this reply. I'd for sure try this, just trying it. Please have a look at my this message too. "The reason I can't put every time is my client has MS Word file, wherein he has written such sort of strings (English-Hindi). I gave him a textbox. What all he does is he copies his string from Word file and pastes those strings in textbox. Then My code fetches that string from texbox (database) and displays it on user panel. I have no control on that string that is in textbox, so I can't put in the string. Please suggest me how can I get this done in easy steps." Thanks..!! – still alone Jun 19 '13 at 10:13