Let a color below represent a single character in UTF-8 encoding ,
which means that each color can span multiple bytes , In example below I
denote one byte by one english character . i.e.
'a' or 'b' or 'c' ,etc. below takes one byte :
Let the string is :
x abc def gh ij klmn
now to reverse this UTF-8 encoded string in place in two steps :
1) reverse bytes of a multibyte character in place ,
after this step the string will look like :
x cba fed hg ji nmlk
2) Now apply a normal string reversal algo , i.e , to swap first byte with
last byte , swap second byte to second last byte .. and so on ...
after this step the string will look like :
klmn ij gh def abc x
And look we have reversed an UTF-8 encoded string in place :)
On Fri, Jan 13, 2012 at 11:13 AM, Supraja Jayakumar <
[email protected]> wrote:
> Hi
>
> Normal string will not work I think. Because it is avriable length
> encoding scheme.
>
> On Fri, Jan 13, 2012 at 11:11 AM, [email protected] <
> [email protected]> wrote:
>
>> Is there anything called in-place reversal ??
>> UTF-8 is only encoding similar to ASCII but with a huge charecter set.
>> So normal string reversal would work fine..
>>
>>
>>
>> On Thu, Jan 12, 2012 at 2:02 AM, Ankur Garg <[email protected]> wrote:
>>
>>> How to do this
>>>
>>> Write a function to reverse a UTF-8 encoded string in-place ??
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> U
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.