Modify

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 TicketCleanup, 18 years ago

Milestone: 3.2.11.2

Automatic ticket cleanup.

comment:2 by Gary, 18 years ago

Owner: changed from Gary to Jos
Status: newassigned

comment:3 by Valik, 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.

in reply to:  3 comment:4 by Jos, 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

comment:5 by Jos, 18 years ago

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 J-Paul Mesnage, 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

in reply to:  6 comment:7 by Jos, 18 years ago

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, 18 years ago

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.