Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9165 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Add ljust, rjust and center to the UTF8Handler

Reported by: hju Assigned to: core
Priority: normal Milestone:
Component: ActiveSupport Version: edge
Severity: normal Keywords: rjust ljust center multibyte verified
Cc:

Description

ljust, rjust, center do not work properly for utf-8 strings.

Seems like the routines use the byte length of the string instead of chars.length to perform the padding.

s="G\303\274\nther"

s.chars.length returns 7 wich is ok, but only 2 extra spaces are added to the string in the result of s.chars.rjust(10)

Attachments

add_rjust_ljust_and_center_to_utf8_handler.diff (5.8 kB) - added by manfred on 08/02/07 07:48:38.

Change History

08/02/07 07:48:38 changed by manfred

  • attachment add_rjust_ljust_and_center_to_utf8_handler.diff added.

08/02/07 07:50:47 changed by manfred

  • keywords changed from rjust ljust center to rjust ljust center multibyte.
  • version changed from 1.2.3 to edge.
  • summary changed from chars.ljust, chars.rjust, chars.center do not work properly for utf-8 strings to [PATCH] Add ljust, rjust and center to the UTF8Handler.

Yes, that was because rjust, ljust and center weren't implemented yet. Attached is a patch to Edge that adds these methods.

08/02/07 10:09:18 changed by lifofifo

+1

08/02/07 12:04:44 changed by norbert

Get live with it. +1

08/02/07 17:36:48 changed by kampers

  • keywords changed from rjust ljust center multibyte to rjust ljust center multibyte verified.

+1, tests and implementation are swell. rock 'n roll.

08/05/07 00:48:03 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

(In [7272]) Add ljust, rjust and center to utf8-handler. Closes #9165 [manfred]