Modify ↓
Opened 11 years ago
Closed 11 years ago
#2914 closed Bug (Rejected)
_StringProper - Diacratic Char issue
| Reported by: | mLipok | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | Standard UDFs | |
| Version: | 3.3.13.19 | Severity: | None |
| Keywords: | Cc: |
Description
Here is repro script:
#include <string.au3>
ConsoleWrite(@CR)
ConsoleWrite('_StringProper:' & @CR)
ConsoleWrite(_StringProper('SOSNOWIEC') & @CR)
ConsoleWrite(_StringProper('Jastrzębie-Zdrój') & @CR)
ConsoleWrite(_StringProper('Wodzisław ŚLĄSKI') & @CR)
ConsoleWrite(@CR)
ConsoleWrite('_StringProper_My:' & @CR)
ConsoleWrite(_StringProper_My('SOSNOWIEC') & @CR)
ConsoleWrite(_StringProper_My('Jastrzębie-Zdrój') & @CR)
ConsoleWrite(_StringProper_My('Wodzisław ŚLĄSKI') & @CR)
ConsoleWrite(@CR)
ConsoleWrite('_StringProper_My_2:' & @CR)
ConsoleWrite(_StringProper_My_2('SOSNOWIEC') & @CR)
ConsoleWrite(_StringProper_My_2('Jastrzębie-Zdrój') & @CR)
ConsoleWrite(_StringProper_My_2('Wodzisław ŚLĄSKI') & @CR)
ConsoleWrite(@CR)
; modified _StringProper()
Func _StringProper_My($sString)
Local $bCapNext = True, $sChr = "", $sReturn = ""
For $i = 1 To StringLen($sString)
$sChr = StringMid($sString, $i, 1)
Select
Case $bCapNext = True
; added ąĄćĆęĘłŁńŃóÓśŚżŻźŹ
If StringRegExp($sChr, '(?i)[a-zA-ZĂ€-ÿšœžŸąĄćĆęĘłŁńŃóÓśŚżŻźŹ]') Then
$sChr = StringUpper($sChr)
$bCapNext = False
EndIf
; added ąĄćĆęĘłŁńŃóÓśŚżŻźŹ
Case Not StringRegExp($sChr, '(?i)[a-zA-ZĂ€-ÿšœžŸąĄćĆęĘłŁńŃóÓśŚżŻźŹ]')
$bCapNext = True
Case Else
$sChr = StringLower($sChr)
EndSelect
$sReturn &= $sChr
Next
Return $sReturn
EndFunc ;==>_StringProper_My
; modified _StringProper()
Func _StringProper_My_2($sString)
Local $bCapNext = True, $sChr = "", $sReturn = ""
For $i = 1 To StringLen($sString)
$sChr = StringMid($sString, $i, 1)
Select
Case $bCapNext = True
; added ąĄćĆęĘłŁńŃóÓśŚżŻźŹ
; removed €
If StringRegExp($sChr, '(?i)[a-zA-ZĂ-ÿšœžŸąĄćĆęĘłŁńŃóÓśŚżŻźŹ]') Then
$sChr = StringUpper($sChr)
$bCapNext = False
EndIf
; added ąĄćĆęĘłŁńŃóÓśŚżŻźŹ
; removed €
Case Not StringRegExp($sChr, '(?i)[a-zA-ZĂ-ÿšœžŸąĄćĆęĘłŁńŃóÓśŚżŻźŹ]')
$bCapNext = True
Case Else
$sChr = StringLower($sChr)
EndSelect
$sReturn &= $sChr
Next
Return $sReturn
EndFunc ;==>_StringProper_My_2
Results (correct are from _StringProper_My_2)
_StringProper: Sosnowiec JastrzęBie-ZdróJ WodzisłAw ŚlĄSki _StringProper_My: SOSNOWIEC Jastrzębie-Zdrój Wodzisław ŚLĄSKI _StringProper_My_2: Sosnowiec Jastrzębie-Zdrój Wodzisław Śląski
Attachments (0)
Change History (3)
comment:1 Changed 11 years ago by jchd18
comment:2 Changed 11 years ago by mLipok
excellent
comment:3 Changed 11 years ago by guinness
- Resolution set to Rejected
- Status changed from new to closed
There are too many variables to include for a function such as this.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.

Too specific in that you don't handle enough of Unicode.
#include <string.au3> _ConsoleWrite('_StringProper_My:' & @CR) _ConsoleWrite(_StringProper_My('SOSNOWIEC МОСКВА-КАЗАНСКИЙ ВОКЗАЛ ПЖДП') & @CR) _ConsoleWrite(_StringProper_My('Jastrzębie-Zdrój ặἷἭὪἢῶ') & @CR) _ConsoleWrite(_StringProper_My('Wodzisław ŚLĄSKI grÖßEN') & @CR) ; Language-independant version Func _StringProper_My($s) Return(Execute('"' & StringRegExpReplace($s, '(*UCP)(\b\pL)(\pL*)', """ & StringUpper('\1') & StringLower('\2') & """) & '"')) EndFunc ; display UTF8 correctly in SciTE console Func _ConsoleWrite($s) ConsoleWrite(BinaryToString(StringToBinary($s, 4), 1)) EndFuncExecute() is frown upon by some in standard UDF.