Modify

#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 TicketCleanup, on Feb 29, 2008 at 12:00:31 PM

Milestone: 3.2.11.2

Automatic ticket cleanup.

comment:2 by Gary, on Feb 29, 2008 at 3:22:12 PM

Owner: changed from Gary to Jos
Status: newassigned

comment:3 by Valik, on Feb 29, 2008 at 4:08:35 PM

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.

in reply to:  3 comment:4 by Jos, on Mar 1, 2008 at 10:22:08 PM

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

comment:5 by Jos, on Mar 1, 2008 at 10:24:07 PM

See a extra DoubleQuote slipped into the first regex. should be:

If StringRegExp($s_CurChar, '[a-zA-ZÀ-ÿ]') Then

in reply to:  5 ; comment:6 by Jpm, on Mar 2, 2008 at 12:48:56 PM

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

in reply to:  6 comment:7 by Jos, on Mar 3, 2008 at 8:21:42 PM

Replying to Jpm:

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

Ok, have added those 4 characters too. next will commit the update.

comment:8 by Jos, on Mar 3, 2008 at 8:25:15 PM

Milestone: 3.2.11.2
Resolution: Fixed
Status: assignedclosed

Fixed in version: 3.2.11.2

Modify Ticket

Action
as closed The owner will remain Jos.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.