[Building Sakai] truncating to fit field
Charles Hedrick
hedrick at rutgers.edu
Thu Feb 27 13:00:32 PST 2014
I was hoping a couple of Oracle sites would say “Don’t worry, we all run with NLS_LENGTH_SEMANTICS = char”.
Short of that, substrb appears to be an Oracle function. I’m going through the Sakai data layer, so I don’t have access to that. Furthermore, it could result in half a UTF-8 character. I have found a Java function that will do the job, but I wondered if there was a standard Sakai approach to this. Surely Lessons isn’t the only place with this problem.
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"
More information about the sakai-dev
mailing list