Opened 18 years ago
Closed 18 years ago
#148 closed Bug (Fixed)
_StringProper
| Reported by: | Xenobiologist | Owned by: | Jos |
|---|---|---|---|
| Milestone: | 3.2.11.2 | Component: | Standard UDFs |
| Version: | 3.2.11.1 | Severity: | |
| Keywords: | _StringProper | Cc: |
Description
The func will only work this letters [a-zA-Z]. There are languages which use something like öäü.
Func _StringProper($s_Str) Local $iX = 0 Local $CapNext = 1 Local $s_nStr = "" Local $s_CurChar For $iX = 1 To StringLen($s_Str) $s_CurChar = StringMid($s_Str, $iX, 1) Select Case $CapNext = 1 If StringRegExp($s_CurChar, '[a-zA-Z]') Then $s_CurChar = StringUpper($s_CurChar) $CapNext = 0 EndIf Case Not StringRegExp($s_CurChar, '[a-zA-Z]') $CapNext = 1 Case Else $s_CurChar = StringLower($s_CurChar) EndSelect $s_nStr &= $s_CurChar Next Return ($s_nStr) EndFunc ;==>_StringProper
Mega
Attachments (0)
Change History (8)
comment:1 by , 18 years ago
| Milestone: | 3.2.11.2 |
|---|
comment:2 by , 18 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
follow-up: 4 comment:3 by , 18 years ago
I think that \b may be useful here for finding word start positions so that the letter can be passed to StringUpper(). Just something to think about for whoever tries to fix this.
comment:4 by , 18 years ago
Replying to Valik:
I think that \b may be useful here for finding word start positions so that the letter can be passed to StringUpper(). Just something to think about for whoever tries to fix this.
Changing the test to this seems to work fine:
StringRegExp($s_CurChar, '[a-zA-ZÀ-ÿ"]')
Does anybody see any issues with that ?
Whole new UDF:
Func _StringProper($s_Str) Local $iX = 0 Local $CapNext = 1 Local $s_nStr = "" Local $s_CurChar For $iX = 1 To StringLen($s_Str) $s_CurChar = StringMid($s_Str, $iX, 1) Select Case $CapNext = 1 If StringRegExp($s_CurChar, '[a-zA-ZÀ-ÿ"]') Then $s_CurChar = StringUpper($s_CurChar) $CapNext = 0 EndIf Case Not StringRegExp($s_CurChar, '[a-zA-ZÀ-ÿ]') $CapNext = 1 Case Else $s_CurChar = StringLower($s_CurChar) EndSelect $s_nStr &= $s_CurChar Next Return ($s_nStr) EndFunc ;==>_StringProper
follow-up: 6 comment:5 by , 18 years ago
See a extra DoubleQuote slipped into the first regex. should be:
If StringRegExp($s_CurChar, '[a-zA-ZÀ-ÿ]') Then
follow-up: 7 comment:6 by , 18 years ago
Replying to Jos:
See a extra DoubleQuote slipped into the first regex. should be:
If StringRegExp($s_CurChar, '[a-zA-ZÀ-ÿ]') Then
only people using šœž or Ÿ will have objections
comment:7 by , 18 years ago
comment:8 by , 18 years ago
| Milestone: | → 3.2.11.2 |
|---|---|
| Resolution: | → Fixed |
| Status: | assigned → closed |
Fixed in version: 3.2.11.2

Automatic ticket cleanup.