🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internationalization
Article #675

Re: Bi-directional mode of locale language's encoding, free component for answer

#675
From: Igor Siticov
Date: Tue, 13 Aug 2002 07:35
113 lines
4376 bytes
Sorry for delay, I was out of my office.
Please find below the C++ interpretation:

bool IsLangMiddleEast(int ALCID)
{
  char BufferA[128];
  unsigned short BufferW[128];
  char * PCharA;
  for (int i = 128; i <= 255; i++)
    BufferA[i - 128] = i;
  PCharA = BufferA;
  GetStringTypeEx(ALCID, CT_CTYPE2, PCharA, 128, BufferW);
  for (int i = 128; i <= 255; i++)
  {
    if (BufferW[i - 128] == C2_RIGHTTOLEFT) return true;
  }
  return false;
}


void __fastcall TForm1::Button1Click(TObject *Sender)
{
  if (IsLangMiddleEast(LANG_ARABIC))
    ShowMessage("RTL");
  else
    ShowMessage("LTR");
}

--
Best regards
Igor Siticov
SiComponents home page: http://www.sicomponents.com
"Edward Diener" <eddielee@tropicsoft.com> wrote in message
news:3d53d02d_2@dnews...
> My interpretation of your technique, as a C++ programmer, is that if
> GetStringTypeEx returns right to left for any of the characters between
code
> 128 and 255, then it is a right-to-left language, else it is a
left-to-right
> language. Is this correct ? My OP is pretty rusty from never having
> programmed in that language.
>
> "Igor Siticov" <support@sicomponents.com> wrote in message
> news:3d53699b_2@dnews...
> > Hello,
> > Below is example code how to detect Right-To-Left from LCID.
> > Unfortunately, I have no time to convert this code to C++ but it is very
> > simply so you can convert it easy.
> >
> > function IsLangMiddleEast(ALCID: integer): boolean;
> > var
> >   I: Integer;
> >   BufferA: array [128..255] of Char;
> >   BufferW: array [128..256] of Word;
> >   PCharA: PChar;
> > begin
> >   for I := Low(BufferA) to High(BufferA) do
> >     BufferA[I] := Char(I);
> >   PCharA := @BufferA;
> >   GetStringTypeEx(ALCID, CT_CTYPE2, PCharA, High(BufferA) - Low(BufferA)
+
> > 1, BufferW);
> >   for I := Low(BufferA) to High(BufferA) do
> >   begin
> >     Result := BufferW[I] = C2_RIGHTTOLEFT;
> >     if Result then
> >       Exit;
> >   end;
> > end;
> >
> > procedure TForm1.Button1Click(Sender: TObject);
> > begin
> >   if IsLangMiddleEast(LANG_ARABIC) then
> >     ShowMessage('RTL')
> >   else
> >     ShowMessage('LTR');
> > end;
> >
> >
> >
> > --
> > Best regards
> > Igor Siticov
> > SiComponents home page: http://www.sicomponents.com
> > "Edward Diener" <eddielee@tropicsoft.com> wrote in message
> > news:3d529c4d_2@dnews...
> > > If anyone can answer this, they get a free component of mine.
> > >
> > > Is there a way to programatically determine the bi-directional mode,
> > either
> > > left-to-right or right-to-left, of a given locale's LCID ? For
instance,
> > > while most languages are left-to-right, Hebrew and Arabic are
> > right-to-left.
> > > However, I do not want to hard-code the fact that the Hebrew or Arabic
> > LCID
> > > has a right-to-left bi-directional mode but instead somehow pick up
the
> > > bi-directional mode programatically from a LCID, since there may be
> other
> > > LCIDs whose language encoding are right-to-left.
> > >
> > > I need this information to programatically set the bi-directional mode
> of
> > an
> > > Edit control at run-time.
> > >
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID: <3d58a821@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!207.8.186.117.MISMATCH!grr!newsprint.netaxs.com!128.230.129.106.MISMATCH!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!isdnet!195.25.12.36.MISMATCH!oleane.net!oleane!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews!not-for-mail
References: <3d529c4d_2@dnews> <3d53699b_2@dnews> <3d53d02d_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10297d,82651872594c01c3,start
X-Google-Attributes: gid10297d,public
X-Google-ArrivalTime: 2002-08-12 23:47:13 PST
From: "Igor Siticov" <support@sicomponents.com>
Newsgroups: borland.public.cppbuilder.internationalization
References: <3d529c4d_2@dnews> <3d53699b_2@dnews> <3d53d02d_2@dnews>
Subject: Re: Bi-directional mode of locale language's encoding, free component for answer
Date: Tue, 13 Aug 2002 09:35:45 +0200
Lines: 115
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 195.22.245.238
Message-ID: <3d58a821@dnews>
X-Trace: dnews 1029220385 195.22.245.238 (12 Aug 2002 23:33:05 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!207.8.186.117.MISMATCH!grr!newsprint.netaxs.com!128.230.129.106.MISMATCH!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!isdnet!195.25.12.36.MISMATCH!oleane.net!oleane!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!dnews!not-for-mail