[Building Sakai] truncating to fit field

Sam Ottenhoff ottenhoff at longsight.com
Thu Feb 27 14:12:52 PST 2014


Adding code to work around this seems wrong.  Isn't the issue that your
database was setup with a non-multibyte character set which means that the
length calculations Oracle is making are based on one byte = one character?
 Our confluence page (
https://confluence.sakaiproject.org/display/I18N/Common+UTF-8+Problems)
recommends "AL32UTF8".

Can any of our Oracle-using institutions chime in here?  If the database is
setup initially with a multi-byte character set, are the tables created
correctly where the length of SAKAI_SITE_GROUP/TITLE is 99 multi-byte
characters and not 99 bytes?

--Sam



On Thu, Feb 27, 2014 at 4:49 PM, Charles Hedrick <hedrick at rutgers.edu>wrote:

> my new code uses this: https://gist.github.com/lpar/1031951, except for
> mysql, where a substring will do (because it interprets limits as
> characters, not bytes).
>
> Yuck.
>
> This is LSNBLDR-352.
>
> On Feb 27, 2014, at 3:54 PM, Steve Swinsburg <steve.swinsburg at gmail.com>
> wrote:
>
> The field is declared wrong, if it's going to store utf8 but use substrb
> or substrc to trim the string in bytes or utf8 chars.
>
> Cheers
> Steve
>
> sent from my mobile device
> On 28/02/2014 3:29 AM, "Charles Hedrick" <hedrick at rutgers.edu> wrote:
>
>> I am generating a group name. The maximum length is 99 characters. In
>> mysql it appears that truncating to 99 characters is fine, because mysql
>> interprets field lengths in characters.
>>
>> However in Oracle, unless the declaration uses "char", it is understood
>> to be bytes. That means that UTF-8 characters can take more than one space.
>> Is there some standard method in Sakai to truncate a string to a length
>> that will fit into a given database field?
>>
>> Unfortunately, the SAKAI_SITE_GROUP is defined in oracle using field
>> names without "char" after them.
>>
>>
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to
>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>> "unsubscribe"
>>
>
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to
> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
> "unsubscribe"
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20140227/dd7e37ce/attachment.html 


More information about the sakai-dev mailing list