Jump to content

Need code to see if the string is written from right to left or left to right.


Guest
 Share

Recommended Posts

Not every string will be written in English .. There some languages ​​written from right to left ..

I need the code will return me an answer if the string is written from right to left or left to right.

Thanks for helpers!

Link to comment
Share on other sites

I'm under the assumption this can't be done.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Well with out more specifics the only two ways I can see it being possible is to look up the machine's language setting using @OSLang and then if the language code matches one of your languages you are planning on supporting it could figure it out. The only other way is if the user selects the language they are using via a dropdown box perhaps or some other type of selection window as part of the interface. Either way I think you'll have to hard code in which languages you want to support in some fashion and whether they work L to R or R to L.

Link to comment
Share on other sites

Maybe if you do an automatic search for the words or sentences on google you might get a pretty good impression -bassed upon the number of results- if the word excists in the current form. Checking left to right vs right to left

?

Edited by Rutger83
Link to comment
Share on other sites

If the string is in unicode UTF-8, and I presume it will be, then you could look for the code blocks. Let's take arabic as an example. If you know the unicode ranges you can do a regexp test to see if they're in the string.

; A character range of the following unicode blocks:
;x{0600}-x{06FF} - Arabic block.
;x{0750}-x{077F} - Arabic supplement block.
; I also had to include a space to get a positive match, you'll have to add more blocks and punctuation yourself.
$sArabicRegExp = '^[ x{0600}-x{06FF}x{0750}-x{077F}]+$' ; Note the whitespace.
$sArabicSentence = 'لغتي العربية ليست كما يجب' ; My Arabic is bad.
$sEnglishSentence = 'My English is much better'
MsgBox(0, 'Arabic sentence', StringRegExp($sArabicSentence, $sArabicRegExp))
MsgBox(0, 'English sentence', StringRegExp($sEnglishSentence, $sArabicRegExp))

You can do this for each Right-To-Left language.

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

When I run this code

$sArabic = "‏‏الأبجدية العربية"
MsgBox(0, "Test", $sArabic)

then the messagebox will be displayed from rtl. That means there must be a winapi call to get the language type...

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This is a complext question, to which you don't define the job.

Take f.ex κεράτιο(ν) > قيراط > carat > карат

How will you determine that sentence ? It contains both.

Windows IME automagically assigns a RTL write order inside the arab text, but not sure if you can read out the direction just by looking at it.

I would take the same approach as dany (you beat me to this one by 1 min ;) ). There are very few languages written RTL.

See this reference and notice that "Arabic" is the script style, not the language.

You should be able to find code blocks for all 2-3 RTL languages. Mainly 2 are used.

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

When I run this code

$sArabic = "‏‏الأبجدية العربية"
MsgBox(0, "Test", $sArabic)

then the messagebox will be displayed from rtl. That means there must be a winapi call to get the language type...

Why not take a deep look at UniScribe ? http://msdn.microsoft.com/en-us/library/windows/desktop/dd374091%28v=vs.85%29.aspx

This is responsible for rendering fonts etc on Windows (at least Win7)

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

Windows IME automagically assigns a RTL write order inside the arab text, but not sure if you can read out the direction just by looking at it.

I put some arabic in a label and it's left-to-right. The label is just as wide as the GUI but the text is aligned incorrectly. I guess this only applies to things like MSgBoxes and ToolTips and the likes where most work is done by WinAPI itself and not the script.

Skimming through WinAPI and WinAPIEx I didn't find any function that could detect text direction.

edit: Nice find Myicq! Didn't know about that. Also look at DirectWrite http://msdn.microsoft.com/en-us/library/windows/desktop/dd368038%28v=vs.85%29.aspx its replacement on the latest Windows versions.

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

Thank you! You always help ..

I will review some codes given here.

Meanwhile, I have a question.

Is there a command that can return the language of a certain letter?

If so then I just need to know the list of languages ​​in which written from left to right and the list of languages ​​in which written from right to left.

Then I can write on the basis of this command and the information a Code for this purpose.

When I run this code

$sArabic = "‏‏الأبجدية العربية"
MsgBox(0, "Test", $sArabic)

then the messagebox will be displayed from rtl. That means there must be a winapi call to get the language type...

Br,

UEZ

Okay.

This is very interesting because it does not work on Hebrew.

Edited by Guest
Link to comment
Share on other sites

Is there a command that can return the language of a certain letter?

With some adaptation on my regexp pattern yes. It's the easiest way to go about this I know of currently, checking if a string/character is inside a specific code block within the unicode range. I'm going to look at UniScribe and DirectWrite later. Who knows what they've got to offer.

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...