0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Oracleで全角を2バイト換算で文字列のバイト数取得

Last updated at Posted at 2023-08-12

概要

まず、Oracleの文字コードが『AL32UTF8』環境の前提です。

その場合、下記の結果は『3』。

LENGTHB('あ')

このLENGTHB()について、シフトJISのように全角文字を2バイト換算させたい。

やり方

CONVERT() でシフトJISに変換してから LENGTHB()

LENGTHB(CONVERT('あいうえお001', 'JA16SJIS'))

上記の結果は『13』。

『あいうえお』部分は2バイト×5文字=10バイト。
『001』部分は3バイト。

参考サイトさん

バージョン

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?