Analysis and preparation of sugars