home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / utility / uintl.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  3.7 KB  |  94 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "uintl.h"
  20. #include "resgui.h"
  21. #include "uprefd.h"
  22. #include "intl_csi.h"
  23.  
  24. INTL_Encoding_ID ScriptToEncoding(ScriptCode script)
  25. {
  26.     switch(script)
  27.     {
  28.         case smRoman:            return CS_MAC_ROMAN;        //    = 0,                            /*Roman*/
  29.         case smJapanese:        return CS_SJIS;                //    = 1,                            /*Japanese*/
  30.         case smTradChinese:        return CS_BIG5;                //    = 2,                            /*Traditional Chinese*/
  31.         case smKorean:            return CS_KSC_8BIT;            //    = 3,                            /*Korean*/
  32. //        case smArabic:                    //    = 4,                            /*Arabic*/
  33. //        case smHebrew:                    //    = 5,                            /*Hebrew*/
  34.         case smGreek:            return CS_MAC_GREEK;        //    = 6,                            /*Greek*/
  35.         case smCyrillic:        return CS_MAC_CYRILLIC;        //    = 7,                            /*Cyrillic*/
  36. //        case smRSymbol:                    //    = 8,                            /*Right-left symbol*/
  37. //        case smDevanagari:                //    = 9,                            /*Devanagari*/
  38. //        case smGurmukhi:                //    = 10,                            /*Gurmukhi*/
  39. //        case smGujarati:                //    = 11,                            /*Gujarati*/
  40. //        case smOriya:                    //    = 12,                            /*Oriya*/
  41. //        case smBengali:                    //    = 13,                            /*Bengali*/
  42. //        case smTamil:                    //    = 14,                            /*Tamil*/
  43. //        case smTelugu:                    //    = 15,                            /*Telugu*/
  44. //        case smKannada:                    //    = 16,                            /*Kannada/Kanarese*/
  45. //        case smMalayalam:                //    = 17                            /*Malayalam*/
  46. //        case smSinhalese:                //    = 18,                            /*Sinhalese*/
  47. //        case smBurmese:                    //    = 19,                            /*Burmese*/
  48. //        case smKhmer:                    //    = 20,                            /*Khmer/Cambodian*/
  49. //        case smThai:                    //    = 21,                            /*Thai*/
  50. //        case smLaotian:                    //    = 22,                            /*Laotian*/
  51. //        case smGeorgian:                //    = 23,                            /*Georgian*/
  52. //        case smArmenian:                //    = 24,                            /*Armenian*/
  53.         case smSimpChinese:        return CS_GB_8BIT;            //    = 25,                            /*Simplified Chinese*/
  54. //        case smTibetan:                    //    = 26,                            /*Tibetan*/
  55. //        case smMongolian:                //    = 27,                            /*Mongolian*/
  56. //        case smGeez:                    //    = 28,                            /*Geez/Ethiopic*/
  57. //        case smEthiopic:                //    = 28,                            /*Synonym for smGeez*/
  58.         case smEastEurRoman:    return CS_MAC_CE;            //    = 29,                            /*Synonym for smSlavic*/
  59. //        case smVietnamese:                //    = 30,                            /*Vietnamese*/
  60. //        case smExtArabic:                //    = 31,                            /*extended Arabic*/
  61. //        case smUninterp:                //    = 32,                            /*uninterpreted symbols, e.g. palette symbols*/
  62.         default:    return CS_MAC_ROMAN;
  63.     }
  64. }
  65.  
  66. // Returns default document csid which is the current
  67. // selection of the encoding menu.
  68. //
  69. uint16 FE_DefaultDocCharSetID(iDocumentContext context)
  70. {
  71. #pragma unused(context) 
  72.  
  73.     uint16        csid;
  74.     CommandT    iCommand;
  75.     ResIDT        outMENUid;
  76.     MenuHandle    outMenuHandle;
  77.     Int16        outItem;
  78.     CharParameter    markChar;
  79.  
  80.     for (csid = CS_DEFAULT, iCommand = ENCODING_BASE; iCommand <= ENCODING_CEILING; iCommand++)
  81.     {
  82.         LMenuBar::GetCurrentMenuBar()->FindMenuItem(iCommand, outMENUid, outMenuHandle, outItem);
  83.         ::GetItemMark    (outMenuHandle, outItem, &markChar);
  84.         if (checkMark == markChar)
  85.         {
  86.             csid = (uint16) CPrefs::CmdNumToDocCsid(iCommand);
  87.             break;
  88.         }
  89.     }
  90.     XP_ASSERT(csid != CS_DEFAULT);    // no check mark in the encoding menu
  91.     
  92.     return csid;
  93. }
  94.