Database Code
  Home arrow Database Code arrow Saving multilingual text inside SQL Server...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE CODE

Saving multilingual text inside SQL Server by M. Vadivel
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2002-09-17

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


     

    Saving multilingual text inside SQL Server

    Advantages:

    In most of the sites you would have seen the user downloading a type of font and installing it in their Windows ŕ fonts folder. The users will be able to see the characters of that particular language only after this downloading is done. But if you as the site developer save the Unicode text that represents a language inside a table and display that content in the web page then there is no need of user downloading the font. Isn’t this a great advantage? (For ex: If you are creating a web page in Chinese language then the user would be forced to download some font files which would be approx 6MB.)

    Disadvantage:

    If you like to offer multiple language support to users of your website, it is most important to use the Unicode character strings, nchar, nvarchar, and ntext (where n stands for “National”), for all character data but the sad part is that it would take more storage space than the character strings.

    A small example Web page 1

    Create an html page from where you can copy multilingual text from any site and paste it in a provision given in this page. Please note that I am not concentrating on any client side validations here. So it is your responsibility to add any client side validation according to your needs.

    <Html>
    <Head>
    <Meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <Title>Saving Multilingual character into database</Title>
    </Head> <Body>
    <h3 align="center">Copy multilingual text from any site and paste it inside this textbox before pressing the submit button</h3> <form name="frmInputDB" method="post" action="frmSaveandRetrieve.asp"> <table border=1 align="center"> <tr> <td>Enter your text here :</td> <td><input name="txtMultiLingual"></td></tr> <tr> <td colspan="2" align="center"> <input type=submit name="btnButton" value="Submit"> </td> </tr> </table> <p><p>* Please note that no validation has been done in this page. </form> </Body>
    </Html>

    Did you note the change in the meta tags charset property? Yes you need to specify “utf-8” as your charset so that Unicode characters would be allowed in that page. If you try skipping that line while creating any multilingual web page you would get an error while saving that page. The error would read something like this “Some Unicode characters in the file cannot be represented in the current code page and were replaced by default character…….”.

    Web page 2

    <Html>
    <Head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    </Head>
    <Body>
    <%
    Dim DBConn,strConnection,sql,
    strConnection="---Put your connection string here."
    Set DBConn = Server.CreateObject("Adodb.Connection")
    set Rs=server.CreateObject("ADODB.Recordset")  
    DBConn.Open(strConnection)
    Strdescription = Request.Form("txtMultiLingual")
    sql = "insert into UniTesting(description) values(N'" & Strdescription & "')"
    dbConn.Execute(sql)
    sql = "select id, [description] from UniTesting order by id"
    set Rs=dbConn.execute(sql)%>
    <table border=1>
    <tr>
    <td>Row Id</td>
    <td>Multi-Lingual Text</td>
    </tr>
    <%
    while not rs.EOFResponse.Write ("<tr><td>")Response.Write Rs("id") & "</td><td>" & Rs(1) & "</td><tr>"rs.MoveNextwend%></table></Body>
    </Html>

    If you try to insert data in some language, which isn’t the default language of the OS or SQL Server, then all the characters inserted into the database might be substituted. Since SQL Server 7.0 and 2000 support both Unicode and non-Unicode data types, they require you to use the "N" prefix in front of Unicode string literals (before the open quotes). Just remember: simply place that "N" prefix in front of the string literal you are using. This will allow your data to be inserted without being corrupted, and this would also be a faster process!

    A small DB structure

    CREATE TABLE UniTesting (id int IDENTITY (1, 1) NOT NULL , 
    description nchar (100) NULL)

    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Database Code Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Build Web services with transport-level security using Rational Application Developer V7, Part 1: Build Web services and Web services clients

    Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services.
    FREE! Go There Now!


    NEW! Don't wait! Try the Rational Application Developer (RAD) v7.5 open beta code today

    Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems.
    FREE! Go There Now!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Functional Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications.
    FREE! Go There Now!


    NEW! Try IBM Rational Asset Manager V7.0 online!

    You can now evaluate IBM Rational Asset Manager V7.0 online without installing or configuring it on your own system! Rational Asset Manager helps create, modify, govern, find, and reuse any type of development assets, including SOA and systems development assets. Rational Asset Manager helps you reduce software development costs and improve quality by facilitating the reuse of all types of software development-related assets. Visit developerWorks to learn more about this product and register to explore its capabilities online.
    FREE! Go There Now!


    NEW! Webcast: Calling All Testers! Find Application Vulnerabilities Early in the Development Process Where they are Easier to Fix and Less Risky to your Business

    In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information.
    FREE! Go There Now!


    NEW! Webcast: Extreme transaction processing with WebSphere Extended Deployment

    In this webcast, you'll get an introduction to the eXtreme Transaction Processing (XTP) features of WebSphere Extended Deployment and the common architectural traits required by XTP applications. See how WebSphere Extended Deployment's ObjectGrid feature provides a state-of-the-art infrastructure for hosting XTP applications.
    FREE! Go There Now!


    NEW! Webcast: Introducing the new Information Server and Solutions community: LeverageInformation

    User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges.
    FREE! Go There Now!


    NEW! Webcast: WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!


    NEW! Whitepaper: Achieving consistency between business process models and operational guides

    Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    DATABASE CODE ARTICLES

    - Deployment of the MobiLink Synchronization M...
    - MobiLink Synchronization Wizard in SQL Anywh...
    - Finding Matching Records in Data Access Pages
    - Using the AccessDataSource Control in VS 2005
    - A Closer Look at ADO.NET: The Command Object
    - A Closer Look at ADO.NET: The Connection Obj...
    - Using ADO to Communicate with the Database, ...
    - Code Snippets: Counting Records
    - Constraints In Microsoft SQL Server 2000
    - Multilingual entries into a DB and to be dis...
    - Two combos, one textbox example
    - ADO Recordset Paging
    - SQL Server Database Creator - .NET Version
    - Getting A List of Tables From SQL Server
    - Discussion & Listserv Module by Mike Eck...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 9 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek