Hello. I am taking pains with obtaining fileName including two byte character in switch to FSRef. It aims at the use of a long character string in two byte character world. Aiming at Mac app store. The character used in software is good in English. However, I think the saved file name for the necessity of the language of the country to exist. I asked the following last year. ---------------------- >> FileName returns zero by the following examples. >> >> fileName = files$( _FSRefOpen, "TEXT", "", fsRef ) >> fileName = files$( _FSRefSave, "", fileName, parentFolderRef ) >> >> I think that fileName contains two byte characters (for instance >> "Name is 長谷川" like Japanese, Chinese and Korea etc.) of it. >> How are it done not to limit to Japanese and to recognize two byte >> characters? > > I wonder if NavDialog (rather than files$) will do what you want? > See Files/NavDialog_Demos in examples. > > Bernie ---------------------- NavDialog_demo 4 returns zero to the character string including two byte character. FB_5_4_8_Examples/Text/Localizable strings/LocalizedStringDemo returns zero to two byte character. The methods other than other FSSpec return all zero. The encode of fileName = fn GetLongFileNameFromFSRef( fsRef ) is made UTF8 and fileName including two byte character is obtained from FSRef. It is a problem not to obtain correct fileName in, fileName = files$( _FSRefSave, "", fileName, fileName ) In local fn SaveAsTEXTFile As for me, only fn GetFileFSRef( parentFolderRef, fileName, @fsRef ) knows the method of obtaining fileName from parentFolderRef. fileName is zero at this time, and fileName becomes the name of the parents folder. FileName = files$( _CFURLRefSave, "CFURLRefSave", fileName, fileUrl ) and fn GetNameAsPascalStringFromCFURLRef( fileUrl, @fileName ) It is useless though was tried. There is a problem that garbles even if two byte character is obtained now, does, and is displayed, too. I feel the necessity for inserting this syntax that obtains two byte character that can be done in the header. Try this. 1.The default file is preserved with FutureBasic 5. 2.The paste does the following two byte characters to the file name. Hello world. --> こんにちは世界. 안녕하십니까 세계. 你好世界. 3.The file is opened. --> (Open though it garbles. ) 4.Save As… select for this file and the paste does two byte character to the file name. --> (The error indication goes out. ) Please advise it is effective. Yoshiyuki Thanks. Sample code '----------------------------------- include "Tlbx MoreFilesX.incl" //<?xml version="1.0" encoding="UTF-8"?> //include "plst jp.rsrc" // FBtoC is not effective. include resources "AppIcon.icns" include resources "TEXT.icns" include resources "sEXT.icns" // MacWindows.h // OS X 10.4 or higher toolbox fn HIWindowSetProxyFSRef( WindowRef window, const FSRef *inRef ) = OSStatus // AEDataModel.h _typeFSRef = _"fsrf" begin globals dim as FSRef @ fsRef, @ parentFolderRef dim as single a,b,c,d,e,f dim as str255 aa,bb dim as single a(100),b(100),c(100),d(100),e(100),f(100) dim as str255 aa(100),bb(100) dim as str255 fileName : fileName = "" end globals local fn InitMenu apple menu "About AEOpenDocFileDemo" menu 1, 0, _enable, "File" menu 1, 1, _enable, "Open/O" menu 1, 2, _enable, "Save/S" menu 1, 3, _enable, "Save As..." menu 1, 4, _enable, "Quit/Q" menu end fn local fn GetLongFileNameFromFSRef( ref as ^FSRef ) as str255 '~'1 dim as str255 @ name dim as HFSUniStr255 hsfName dim as CFStringRef cfStr dim as OSErr err dim as boolean result '~'< err = fn FSGetCatalogInfo( #ref, _kFSCatInfoNone, #0, hsfName, #0, #0) if err then stop "FSGetCatalogInfo Error:" + str$( err ) long if ( err == _noErr ) cfStr = fn CFStringCreateWithCharacters( 0, hsfName.unicode[0], hsfName.length ) long if ( cfStr ) result = fn CFStringGetPascalString( cfStr, @name, sizeof( name ), _kCFStringEncodingUTF8 )//_kCFStringEncodingUTF16 _kCFStringEncodingMacRoman // FileName including two bytes is obtained by _kCFStringEncodingUTF8. However, it garbles. CFRelease( cfStr ) end if end if end fn = name local fn OpenDialogTEXTFile '~'1 dim as WindowRef @ w dim as OSStatus ignore dim as OSErr err dim as int i : i = 0 dim as FInfo info dim as integer st dim as FSSpec fspec '~'< fileName = files$( _FSRefOpen, "TEXT", "", fsRef ) // fileName return zero contains two byte characters fileName = fn GetLongFileNameFromFSRef( fsRef ) // Correct fileName obtains contains two byte characters long if ( fileName[0] ) err = fn FSGetCatalogInfo( fsRef, 0, #0, #0, @fspec, #0 ) err = fn FSpGetFInfo( fspec, info ) long if err == 0 st = ( info.fdFlags% and &H0800 )//st > 0 : stationaly if st > 0 then beep : print "name";st end if open "I", #1, @fsRef while ( eof( 1 ) == 0 ) i++ input #1, aa(i),bb(i),a(i),b(i),c(i),d(i) print aa(i),bb(i),a(i),b(i),c(i),d(i) wend close #1 err = fn FSGetCatalogInfo( #fsRef, _kFSCatInfoNone, #0, #0, #0, @parentFolderRef ) get window 1, w ignore = fn HIWindowSetProxyFSRef( w, fsRef ) // Set proxy icon ignore = fn SetWindowModified( w, _false ) // Set close box clean SetWTitle( w, fileName ) xelse beep end if end fn local fn ClickOpenTEXTFile( spec as ^FSSpec, ref as ^FSRef ) '~'1 dim as WindowRef @ w dim as OSErr err dim as OSStatus ignore dim as short i : i = 0 '~'< fsRef = ref def open "TEXTwxyz" open "I", #1, @fsRef while ( eof( 1 ) == 0 ) i++ input #1, aa(i),bb(i),a(i),b(i),c(i),d(i) print aa(i),bb(i),a(i),b(i),c(i),d(i) wend close #1 err = fn FSGetCatalogInfo( #fsRef, _kFSCatInfoNone, #0, #0, #0, @parentFolderRef ) fileName = fn GetLongFileNameFromFSRef( fsRef ) get window 1, w ignore = fn HIWindowSetProxyFSRef( w, fsRef ) // Set proxy icon ignore = fn SetWindowModified( w, _false ) // Set close box clean SetWTitle( w, fileName ) end fn local fn SaveAsTEXTFile '~'1 dim as WindowRef @ w dim as OSStatus ignore dim as OSErr err dim as int i '~'< a(1)=10.5:b(1)=20.123:c(1)=30:d(1)=40:aa(1)="ABCDE":bb(1)="qwert" a(2)=10.5:b(2)=20.123:c(2)=30:d(2)=40:aa(2)="ABCDE":bb(2)="qwert" a(3)=10.5:b(3)=20.123:c(3)=30:d(3)=40:aa(3)="ABCDE":bb(3)="qwert" fileName = files$( _FSRefSave, "", fileName, parentFolderRef ) // fileName return zero contains two byte characters // Correct fileName including two byte character is not obtained. long if ( fileName[0] ) def open "TEXTwxyz" open "O", #1, fileName, @parentFolderRef for i == 1 to 3 print #1, aa(i)","bb(i)","a(i)","b(i)","c(i)","d(i) next close #1 err = fn GetFileFSRef( parentFolderRef, fileName, @fsRef ) get window 1, w ignore = fn HIWindowSetProxyFSRef( w, fsRef ) // Set proxy icon ignore = fn SetWindowModified( w, _false ) // Set close box clean SetWTitle( w, fileName ) for i == 1 to 3 aa(i)="":bb(i)="":a(i)=0:b(i)=0:c(i)=0:d(i)=0 next xelse beep end if end fn local fn SaveTEXTFile '~'1 dim as WindowRef @ w dim as OSStatus ignore dim as int i '~'< a(1)=10.5:b(1)=20.123:c(1)=30:d(1)=40:aa(1)="zxcvb":bb(1)="asdfg" a(2)=10.5:b(2)=20.123:c(2)=30:d(2)=40:aa(2)="ABCDE":bb(2)="qwert" a(3)=10.5:b(3)=20.123:c(3)=30:d(3)=40:aa(3)="zxcvb":bb(3)="asdfg" long if ( fileName[0] ) def open "TEXTwxyz" open "O", #1, fileName, @parentFolderRef for i == 1 to 3 print #1, aa(i)","bb(i)","a(i)","b(i)","c(i)","d(i) next close #1 cls for i == 1 to 3 print aa(i),bb(i),a(i),b(i),c(i),d(i) next get window 1, w ignore = fn SetWindowModified( w, _false ) // Set close box clean xelse beep end if end fn local fn BuildWindow '~'1 dim as Rect r '~'< fn NewWindowPositionMethod(_kWindowCenterOnMainScreen) SetRect(r, 382, 435, 851, 633)// w: 469 h: 198 appearance window -1, "Untitled", @r, _kDocumentWindowClass, _kWindowCloseBoxAttribute fn NewWindowPositionMethod(0) '~'< appearance window 1 end fn local fn DoMenu '~'1 dim as long menuID, itemID '~'< menuID = menu(_menuID) itemID = menu(_itemID) select menuID case 127, 254//Appel Menu select itemID case 1//About Wnd beep end select case 1//File select itemID case 1//Open Dialog window close 1 fn BuildWindow fn OpenDialogTEXTFile case 2//Save fn SaveTEXTFile case 3//Save AS window close 1 fn BuildWindow fn SaveAsTEXTFile end select end select end fn local fn DoSomethingWithFile( spec as ^FSSpec, ref as ^FSRef ) '~'1 window close 1 fn BuildWindow fn ClickOpenTEXTFile( spec, ref ) end fn local fn ProcessUserDocsFromFinder( spec as ^FSSpec, ref as ^FSRef, info as ^FInfo ) '~'1 // check file type and do something with it if ( info.fdType == _"TEXT" ) then fn DoSomethingWithFile( spec, ref ) end fn local fn GetFInfoAndFSSpec( ref as ^FSRef, outInfo as ^FInfo, spec as ^FSSpec ) '~'1 dim as FSCatalogInfo @ catInfo '~'< call FSGetCatalogInfo( #ref, _kFSCatInfoFinderInfo, catInfo, #0, #spec, #0 ) BlockMoveData( @catInfo.finderInfo, outInfo, sizeof( FInfo ) ) end fn local fn HandleOpenDoc( theAppleEvent as ^AEDesc, reply as ^AppleEvent, handlerRefcon as long ) '~'1 dim as AEDesc docList dim as SInt32 @ count, index dim as FSSpec @ spec dim as FSRef @ ref dim as FInfo info '~'< call AEGetParamDesc( theAppleEvent, _keyDirectObject, _typeAEList, docList ) call AECountItems( docList, count ) for index == 1 to count call AEGetNthPtr( docList, index, _typeFSRef, #0, #0, @ref, sizeof ( FSRef ), #0 ) fn GetFInfoAndFSSpec( @ref, @info, @spec ) fn ProcessUserDocsFromFinder( @spec, @ref, @info ) next end fn local fn InstallAEHandlers '~'1 call AEInstallEventHandler( _kCoreEventClass, _kAEOpenDocuments, fn NewAEEventHandlerUPP( @fn HandleOpenDoc ), 0, _false ) end fn fn InitMenu fn InstallAEHandlers() on menu fn DoMenu //RunApplicationEventLoop() do HandleEvents until gFBQuit '-----------------------------------