请考虑以下情况,其中我É
定义了字符串\U00000045\U00000301
。
1)https://www.fileformat.info/info/unicode/char/0045/index.htm
2)https://www.fileformat.info/info/unicode/char/0301/index.htm
受varchar(1)
限制的表是否会将其视为有效的1个字符输入。或者它会被拒绝,因为它被认为是一个2字符输入?
SQL如何通常使用字素来处理字符串的长度?
答案 0 :(得分:1)
我对这个查询看起来很傻,但仍然:
func makeShoot() {
let Shoot:ShootClass = ShootClass.init()
Shoot.physicsBody = SKPhysicsBody(texture: Shoot.texture!,
size: Shoot.texture!.size())
Shoot.position = (self.Shoot?.position)!
Shoot.currentPosition = (self.Shoot?.position)!
Shoot.physicsBody?.isDynamic = true
Shoot.physicsBody?.allowsRotation = false
Shoot.physicsBody?.affectedByGravity = false
Shoot.physicsBody?.friction = 0
Shoot.physicsBody?.restitution = 1
Shoot.physicsBody?.mass = 1
Shoot.physicsBody?.linearDamping = 0.0
Shoot.physicsBody?.angularDamping = 0.0
Shoot.physicsBody?.categoryBitMask = ShootCategory
Shoot.physicsBody?.collisionBitMask = BorderCategory
Shoot.physicsBody?.contactTestBitMask = BorderCategory
PlayingView.addChild(Shoot);
Shoot.physicsBody?.applyImpulse(CGVector(dx: 100, dy: 100))
self.moveNodeToLocation(Shoot: Shoot)
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let curTouch = touches.first!
let curPoint = curTouch.location(in: self)
if ((curPoint.x > 103.5 && curPoint.y > 50.0) || (curPoint.x < 840.0 && curPoint.y > 50.0)) {
StartingPoint = touches.first?.location(in: self)
direction?.isHidden = false
direction?.setScale(0.50)
FirstTouchLocater = SKSpriteNode(imageNamed: "ic_Shootz");
FirstTouchLocater.position = curPoint
FirstTouchLocater.alpha = 0.5
self.addChild(FirstTouchLocater);
}
else{
self.direction?.isHidden = true
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
let point:CGPoint = (touches.first?.location(in: self))!
if point.y < 40 {
return
}
if !(isTouch!) {
isTouch = true
}
let dy:CGFloat = StartingPoint!.y - point.y
let size:CGFloat = dy*10/self.frame.height
if size < 2 && size > 0.50 {
direction?.setScale(size)
}
print("size ======> \(size)")
let curTouch = touches.first!
let curPoint = curTouch.location(in: self)
if (curPoint.x <= ((StartingPoint?.x)! + 20.0)) && ((curPoint.x + 20.0) >= (StartingPoint?.x)!) && (curPoint.y <= ((StartingPoint?.y)! + 20.0)) && ((curPoint.y + 20.0) >= (StartingPoint?.y)!){
self.direction?.isHidden = true
FirstTouchLocater?.isHidden = true
}
else if ((curPoint.x > 103.5 && curPoint.y > 50.0) || (curPoint.x < 840.0 && curPoint.y > 50.0)) {
let deltaX = (self.direction?.position.x)! - curPoint.x
let deltaY = (self.direction?.position.y)! - curPoint.y
let angle = atan2(deltaY, deltaX)
let DegreesToRadians = CGFloat.pi / 180
self.direction?.zRotation = angle + 90 * DegreesToRadians
self.direction?.isHidden = false
FirstTouchLocater?.isHidden = false
}
else{
self.direction?.isHidden = true
FirstTouchLocater?.isHidden = true
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if direction?.isHidden == false {
FirstTouchLocater.removeFromParent()
direction?.isHidden = true
direction?.setScale(0.1)
if timeThrow == nil && isTouch!
{
isTouch = false
counterY = 0;
let touch = touches.first
let touchLocation = touch?.location(in: self)
lastTouch = touchLocation
lastTouch1 = touchLocation
ShootThrow = 2
timeThrow = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(self.loadScreen), userInfo: nil, repeats: true)
}
}
}
func moveNodeToLocation(Shoot:SKSpriteNode) {
let dx = (lastTouch?.x)! - Shoot.position.x
let dy = (lastTouch?.y)! - Shoot.position.y
let speed1:CGFloat = 424
let hypo = hypot(dx, dy)
let newX = (speed1 * dx) / hypo
let newY = (speed1 * dy) / hypo
Shoot.physicsBody?.velocity = CGVector(dx:newX, dy: newY)
}
修改强>
t=# with c(u) as (values( e'\U00000045\U00000301'))
select u, u::varchar(1), u::varchar(2),char_length(u), octet_length(u) from c;
u | u | u | char_length | octet_length
---+---+---+-------------+--------------
É | E | É | 2 | 3
(1 row)