🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.java
1 messages
1 total messages Started by J-23 Thu, 15 May 2014 13:28
getByte('UTF-8'). length
#154014
Author: J-23
Date: Thu, 15 May 2014 13:28
55 lines
3040 bytes
Witam
Piszę w jawie jedną rzecz i potrzebuje sprawdzić ile dane słowo np 
"Warszawa" zawiera miejsca w pamięci zakodowane jako UTF8

zacząłem za tym googlować i znalazłem coś takiego

String s = "Warszawa"
s.getByte('UTF-8').length - zwraca mi bodajrze 7 bajtów

mam pole w tabeli (baza Firebird)
zadeklarowane w ten sposób

KOD	VARCHAR(6)

IBExpert mnoży wielkość tego VARCHAR * 4

http://ibexpert.net/ibe/index.php?n=Doc.ConvertYourFirebirdApplicationsToUnicode

The importance of field size

The extra storage required by different character sets needs to be taken 
into consideration when specifying field size. For example, when you are 
working in a non-Unicode database:

  CREATE TABLE TEST5 (TXT VARCHAR(32000))

is not a problem, even though it’s not necessarily a good idea to define 
your VARCHAR(32000) that big. But you may have a problem in the Unicode 
database, because Firebird has to consider that the information that is 
stored here is could be, for example, a complete list of Chinese 
characters. As every single character needs up to 4 bytes, it must have 
the room to store up to 32000*4. So the actual maximum VARCHAR length 
with UTF8 is 8191 and not 32000.

This also needs to be taken into consideration when you are using 
variables; you have to think about the same issue. You should always 
take into consideration that variables might be subject to internal 
limitation.

And simply replacing your large VARCHARs with blobs is not necessarily 
the solution. Every time you change it, the versions are stored in the 
memory which can have a huge negative impact on server performance. So 
if you do work with variables that are blobs, do not manipulate them too 
often. Or alternatively work on VARCHAR variables and combine them in 
the last step to a single blob.

więc ja również pobieram tę wartość przemnożoną przez 4 co by dawało to 
(24 bajty) ale moje myślenie tutaj jest chyba błędne i nie powinienem 
pomnażać tej wartości przez 4 bo Firebird mi krzyczy że się nie mieści.

i tu pytanie do Was którą wartość powinienem brać pod uwagę to 
przemnożoną bo jak tak to oznacza że coś skopałem przy pobieraniu 
wielkości w bajtach UTF8?

Pozdrawiam
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads