Global It Leader!!



 
 

VB 멀티바이트 형식을 유니코드 형식으로 바꿔주는 함수

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,745회 작성일 13-12-17 09:35

본문

Private Declare Function MultiByteToWideChar Lib "Kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Private Declare Function WideCharToMultiByte Lib "Kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long
Private Declare Function GetACP Lib "Kernel32" () As Long
Private Const CP_ACP = 0 ' default to ANSI code page
Private Const CP_UTF8 = 65001 ' default to UTF-8 code page
'--------------------------------
' AToW
'
' ANSI to UNICODE conversion, via a given codepage.
'--------------------------------
Public Function AToW(ByVal st As String, Optional ByVal cpg As Long = -1, Optional ByVal lFlags As Long = 0) As String
  Dim stBuffer As String
  Dim cwch As Long
  Dim pwz As Long
  Dim pwzBuffer As Long
  If cpg = -1 Then cpg = GetACP()
  pwz = StrPtr(st)
  cwch = MultiByteToWideChar(cpg, lFlags, pwz, -1, 0&, 0&)
  stBuffer = String$(cwch + 1, vbNullChar)
  pwzBuffer = StrPtr(stBuffer)
  cwch = MultiByteToWideChar(cpg, lFlags, pwz, -1, pwzBuffer, Len(stBuffer))
  AToW = Left$(stBuffer, cwch - 1)
End Function
'--------------------------------
' WToA
'
' UNICODE to ANSI conversion, via a given codepage
'--------------------------------
Public Function WToA(ByVal st As String, Optional ByVal cpg As Long = -1, Optional ByVal lFlags As Long = 0) As String
  Dim stBuffer As String
  Dim cwch As Long
  Dim pwz As Long
  Dim pwzBuffer As Long
  Dim lpUsedDefaultChar As Long
  If cpg = -1 Then cpg = GetACP()
  pwz = StrPtr(st)
  cwch = WideCharToMultiByte(cpg, lFlags, pwz, -1, 0&, 0&, ByVal 0&, ByVal 0&)
  stBuffer = String$(cwch + 1, vbNullChar)
  pwzBuffer = StrPtr(stBuffer)
  cwch = WideCharToMultiByte(cpg, lFlags, pwz, -1, pwzBuffer, Len(stBuffer), ByVal 0&, ByVal 0&)
  WToA = Left$(stBuffer, cwch - 1)
End Function
'Use this to encode before you send...
Function EncodeUTF8(ByVal cnvUni As String)
  If cnvUni = vbNullString Then Exit Function
  EncodeUTF8 = WToA(cnvUni, CP_UTF8, 0)
End Function
'Use this to decode received strings...
Function DecodeUTF8(ByVal cnvUni As String)
  If cnvUni = vbNullString Then Exit Function
  cnvUni = WToA(cnvUni, CP_ACP)
  DecodeUTF8 = AToW(cnvUni, CP_UTF8)
End Function
 
 

댓글목록

등록된 댓글이 없습니다.

전체 440
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
260 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4391 12-18
259 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4325 12-18
열람중 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4746 12-17
257 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6780 12-17
256 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4643 12-16
255 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4401 12-16
254 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4527 12-16
253 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6323 12-16
252 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4910 12-09
251 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4359 11-18
250 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4450 11-14
249 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4503 11-10
248 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8856 11-05
247 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4625 10-24
246 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7112 10-24
245 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4246 09-29
244 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4543 09-19
243 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4394 09-19
242 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4728 09-06
241 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4601 08-28