Modify

Opened 11 years ago

Closed 11 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 Changed 11 years ago by TicketCleanup

  • Milestone 3.2.11.2 deleted

Automatic ticket cleanup.

comment:2 Changed 11 years ago by Gary

  • Owner changed from Gary to Jos
  • Status changed from new to assigned

comment:3 follow-up: Changed 11 years ago by 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.

comment:4 in reply to: ↑ 3 Changed 11 years ago by Jos

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 follow-up: Changed 11 years ago by Jos

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

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

comment:6 in reply to: ↑ 5 ; follow-up: Changed 11 years ago by 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

comment:7 in reply to: ↑ 6 Changed 11 years ago by Jos

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 Changed 11 years ago by Jos

  • Milestone set to 3.2.11.2
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed in version: 3.2.11.2

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.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jos.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.